Restoring and Deleting Persistent Disk Snapshots

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

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

  1. Go to the Snapshots page.

    Go to the Snapshots page

  2. Find the name of the snapshot that you want to restore.
  3. Go to the VM instances page.

    Go to the VM instances page

  4. Click the name of the instance where you want to restore your non-boot disk.
  5. At the top of the instance details page, click Edit.
  6. Under Additional disks, click Add item.
  7. In the Name drop-down menu, click Create disk.
  8. 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.
  9. Under Source type, click Snapshot.
  10. Select the name of the snapshot that you want to restore.
  11. (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.
  12. Click Create to create the disk.
  13. At the bottom of the instance details page, click Save to apply your changes to the instance and attach the new disk.

gcloud

  1. Use the gcloud compute snapshots list command to find the name of the snapshot you want to restore:

    gcloud compute snapshots list

  2. Use the gcloud compute snapshots describe command 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.

  3. Use the gcloud compute disks create command to create a new persistent disk from your non-boot snapshot. If you need an SSD persistent disk for additional throughput or IOPS, include the --type flag and specify pd-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.
  4. Use the gcloud compute instances attach-disk command 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:

  1. Any data that is required for restoring other snapshots is moved into the next snapshot, increasing its size.
  2. Any data that is not required for restoring other snapshots is deleted. This lowers the total size of all your snapshots.
  3. 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. As mentioned in the first bullet above, 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.

The diagram below illustrates the process described above:

Diagram describing the
  process for deleting a snapshot

Console

  1. Go to the Snapshots page.

    Go to the Snapshots page

  2. Select one or more snapshots that you want to delete.
  3. 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.

What's next

Was this page helpful? Let us know how we did:

Send feedback about...

Compute Engine Documentation