GCP - Persistent Disk Snapshot vs Disk Image
TL;DR
Feature | Disk Snapshot | Disk Image |
---|---|---|
Primary Goal | Backup & Recovery | Template & Boot Source |
Nature | Incremental (usually), Point-in-time | Full Copy (usually), Self-contained |
Main Use | Restore disk, Create data copy | Create new boot/data disks for VMs |
Created From | Persistent Disk | Disk, Snapshot, Image, GCS File, Import |
Typical Data | Raw disk blocks at a specific time | Bootable OS, Apps, Configs (often) |
Lifecycle | Frequent, Scheduled (often) | Infrequent, As needed for new templates |
In essence:
- Use Snapshots for backing up your live disks regularly so you can recover from data loss or revert changes.
- Use Images to create standardized templates, especially boot disks, for launching new, pre-configured VM instances quickly and consistently.
Persistent Disk Snapshot
- Primary Purpose: Backup and Recovery. Snapshots are designed to create point-in-time backups of your persistent disks (either boot disks or data disks).
- Nature:
- Incremental: By default, after the first full snapshot of a disk, subsequent snapshots are incremental. They only store the blocks that have changed since the previous snapshot, making them faster to create and more storage-efficient.
- Point-in-Time: Captures the exact state of the disk blocks at the moment the snapshot creation begins.
- Source: Created from an existing Persistent Disk attached to a VM (the VM can be running or stopped).
- Use Cases:
- Regularly backing up critical data.
- Recovering a disk to a previous known good state (by creating a new disk from the snapshot).
- Migrating a disk's data to a new zone, region, or project (by creating a new disk from the snapshot in the target location).
- Protecting against accidental data deletion or corruption.
- Lifecycle: Often created on a regular schedule (e.g., daily, weekly) for ongoing protection. Older snapshots might be deleted based on a retention policy.
- Cost: You pay for the storage consumed by the snapshot data (which is often less than the source disk size due to incrementality and compression). Costs vary between standard, instant, and archive snapshot types.
Disk Image
- Primary Purpose: Template for creating new disks, especially boot disks for new VM instances.
- Nature:
- Self-Contained Template: Contains the entire filesystem and data necessary to create a new disk, often including a bootable operating system, configurations, and pre-installed software.
- Full Copy (Generally): Usually represents a full copy of the source data at the time of creation (though the underlying storage might be optimized).
- Source: Can be created from multiple sources:
- An existing Persistent Disk (boot or data).
- A Snapshot.
- Another Image.
- A raw disk file (e.g.,
disk.raw
) stored in Google Cloud Storage. - Virtual disk files (VMDK, VHD, etc.) imported from other platforms (like VMware, VirtualBox, AWS, Azure).
- Use Cases:
- Creating new VM instances with a pre-configured operating system and software stack ("golden image").
- Standardizing VM deployments across your organization.
- Sharing bootable environments with other projects or users (using IAM permissions).
- Importing existing virtual machines from on-premises or other clouds into Google Cloud.
- Lifecycle: Created when a new baseline or template is needed. Often versioned using "Image Families" to point to the latest recommended version.
- Cost: You pay for the storage consumed by the image size for the duration it's stored.