Use snapshots to incrementally back up data from your persistent disks. To learn how to create snapshots, see Creating Persistent Disk Snapshots.
After you create a snapshot, you can restore a snapshot to a persistent disk. To share snapshots across projects, set the correct IAM permissions in your project. To use your snapshots in another project, create a custom image. If you no longer need a specific snapshot, you can reduce storage costs by deleting the snapshot.
To see a list of snapshots available to a project, use the
gcloud compute snapshots list
command:
gcloud compute snapshots list
To list information about a particular snapshot, use the
gcloud compute snapshots describe
command:
gcloud compute snapshots describe [SNAPSHOT_NAME]
where [SNAPSHOT_NAME] is the name of the snapshot you want described.
Before you begin
- If you want to use the command-line examples in this guide:
- Install or update to the latest version of the gcloud command-line tool.
- Set a default region and zone.
- If you want to use the API examples in this guide, set up API access.
- Read about persistent disks.
Restoring a snapshot
Restoring a boot disk snapshot
You can use a snapshot of a boot persistent disk to create a new VM instance. See Creating an instance from a snapshot.
Restoring a non-boot disk snapshot
You can restore a non-boot persistent disk snapshot to a persistent disk that is a larger size than the original snapshot, but you must run some additional commands in the instance for the additional space to be recognized.
Depending on your operating system and filesystem type, you might need to use a different filesystem resizing tool. Please refer to your operating system documentation for more information.
To restore a non-boot persistent disk snapshot:
Console
- Go to the Snapshots page in the Google Cloud Platform Console.
- Find the name of the snapshot that you want to restore.
- Go to the VM instances page.
- Click the name of the instance where you want to restore your non-boot disk.
- At the top of the instance details page, click Edit.
- Under Additional disks, click Add item.
- In the Name drop-down menu, click Create disk.
- Specify the following configuration parameters:
- A name for the disk.
- A type for the disk. The type selected should match the type used for the snapshot.
- Under Source type, click Snapshot.
- Select the name of the snapshot that you want to restore.
- (Optional) Select a size for the disk in GB. This number must be equal to or larger than the snapshot size. If not specified, the size is set to that of the snapshot.
- Click Create to create the disk.
- At the bottom of the instance details page, click Save to apply your changes to the instance and attach the new disk.
gcloud
Use the
gcloud compute snapshots listcommand to find the name of the snapshot you want to restore:gcloud compute snapshots listUse the
gcloud compute snapshots describecommand to find the size of the snapshot you want to restore:gcloud compute snapshots describe [SNAPSHOT_NAME]
where [SNAPSHOT_NAME] is the name of the snapshot being restored.
Use the
gcloud compute disks createcommand to create a new regional or zonal persistent disk from your non-boot snapshot. If you need an SSD persistent disk for additional throughput or IOPS, include the--typeflag and specifypd-ssd.gcloud compute disks create [DISK_NAME] --size [DISK_SIZE] \ --source-snapshot [SNAPSHOT_NAME] \ --type [DISK_TYPE]
where:
+ `[DISK_NAME]` is the name of the new disk.
+ `[DISK_SIZE]` is the size of the new disk in GB. This number must be
equal to or larger than the snapshot size.
+ `[SNAPSHOT_NAME]` is the name of the snapshot being restored.
+ `[DISK_TYPE]` is the type of persistent disk, either `pd-standard` or
`pd-ssd`.
Use the
gcloud compute instances attach-diskcommand to attach your persistent disk to an instance:gcloud compute instances attach-disk [INSTANCE_NAME] \ --disk [DISK_NAME]
where:
+ `[INSTANCE_NAME]` is the name of the instance.
+ `[DISK_NAME]` is the name of the disk made from your snapshot.
If your disk is larger than the snapshot size, you need to resize the filesystem on that persistent disk to include the additional disk space.
You can now use the instance to access the restored data and use the extra persistent disk space to store new data.
Deleting a snapshot
Compute Engine uses incremental snapshots so that each snapshot contains only the data that has changed since the previous snapshot. For unchanged data, snapshots reference the data in previous snapshots. Storage costs for persistent disk snapshots charge only for the total size of the snapshot.
When you delete a snapshot, Compute Engine immediately marks the
snapshot as DELETED in the system. If the snapshot has no dependent snapshots,
it is deleted outright. However, if the snapshot does have dependent snapshots:
- Any data that is required for restoring other snapshots is moved into the next snapshot, increasing its size.
- Any data that is not required for restoring other snapshots is deleted. This lowers the total size of all your snapshots.
- The next snapshot no longer references the snapshot marked for deletion, and instead references the snapshot before it.
Because subsequent snapshots might require information stored in a previous snapshot, keep in mind that deleting a snapshot does not necessarily delete all the data on the snapshot. If any data on a snapshot that is marked for deletion is needed for restoring subsequent snapshots, that data is moved into the next corresponding snapshot. To definitively delete data from your snapshots, you should delete all snapshots.
If your disk has a snapshot schedule, you must detach the snapshot schedule from the disk before you can delete the schedule. Removing the snapshot schedule from the disk prevents further snapshot activity from occurring. You cannot delete a schedule that is attached to a disk. You have the option to manually delete snapshots at any time.
The diagram below illustrates the process described above:
To delete a snapshot:
Console
- Go to the Snapshots page in the Google Cloud Platform Console.
- Select one or more snapshots that you want to delete.
- At the top of the Snapshots page, click Delete.
gcloud
To delete a snapshot, use the
gcloud compute snapshots delete
command:
gcloud compute snapshots delete [SNAPSHOT_NAME]
where [SNAPSHOT_NAME] is the name of the snapshot being deleted.
API
Make a DELETE request to compute.snapshots.delete
to delete snapshots.
DELETE https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/global/snapshots/[SNAPSHOT_NAME]
where:
+ `[PROJECT_ID]` is the name of your project.
+ `[SNAPSHOT_NAME]` is the name of the snapshot to delete.
What's next
- Learn how to manage access to snapshots.
- Learn how to create a disk image from your snapshot.
- Learn how to create scheduled snapshots for persistent disks with a retention policy.


