Creating persistent disk snapshots

Create snapshots to periodically back up data from your zonal persistent disks or regional persistent disks. To reduce the risk of unexpected data loss, consider the best practice of setting up a snapshot schedule to ensure your data is backed up on a regular schedule.

If you want to delete a snapshot or if you want to restore the data from a snapshot to a persistent disk, see Restoring and deleting persistent disk snapshots.

Before you begin

You can create snapshots from disks even while they are attached to running instances. Snapshots are global resources, so any snapshot is accessible by any resource within the same project. You can also share snapshots across projects. Note that snapshots are different from public images and custom images, which are primarily used to create boot disks for instances or to configure the boot disks for instance templates.

Snapshots are incremental and automatically compressed, so you can create regular snapshots on a persistent disk faster and at a much lower cost than if you regularly created a full image of the disk. Incremental snapshots work in the following manner:

  • The first successful snapshot of a persistent disk is a full snapshot that contains all the data on the persistent disk.
  • The second snapshot only contains any new data or modified data since the first snapshot. Data that hasn't changed since snapshot 1 isn't included. Instead, snapshot 2 contains references to snapshot 1 for any unchanged data.
  • Snapshot 3 contains any new or changed data since snapshot 2 but won't contain any unchanged data from snapshot 1 or 2. Instead, snapshot 3 contains references to blocks in snapshot 1 and snapshot 2 for any unchanged data.

This repeats for all subsequent snapshots of the persistent disk. Snapshots are always created based on the last successful snapshot taken.

Diagram describing how to create a snapshot

Compute Engine stores multiple copies of each snapshot across multiple locations with automatic checksums to ensure the integrity of your data. Use IAM roles to share snapshots across projects.

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, such as the creation time, size, and source disk, use the gcloud compute snapshots describe command:

gcloud compute snapshots describe [SNAPSHOT_NAME]

where [SNAPSHOT_NAME] is the name of the snapshot for which you want to see the snapshot information.

Selecting the storage location for a snapshot

When you create a snapshot, you can specify a storage location. The location of a snapshot affects its availability and can incur networking costs when creating the snapshot or restoring it to a new disk.

Snapshots can be stored in either one Cloud Storage multi-regional location, such as asia, or one Cloud Storage regional location, such as asia-south1.

A multi-regional storage location provides higher availability and might reduce network costs when creating or restoring a snapshot. For example, creating a disk from a snapshot stored in a multi-regional location does not incur network costs as long as the new persistent disk is created in one of the regions of the multi-regional group. A regional storage location gives you more control over the physical location of your data because you specify a single region.

If you do not specify a storage location for a snapshot, GCP uses the default location, which stores your snapshot in a Cloud Storage multi-regional location closest to the region of the source disk. If you need to choose regional storage, or if you need to specify a different multi-regional location, store your snapshot in a custom location.

Default location

If you do not specify a storage location, your snapshot is stored in the multi-region that is geographically closest to the location of your persistent disk.

For example, if your persistent disk is stored in us-central1 your snapshot will be stored in the us multi-region by default.

However, a default location like australia-southeast1 is outside of a multi-region. The closest multi-region is asia. Creating or restoring a snapshot will generate network costs.

Some example use cases for choosing a default location to store your snapshots are:

  • The default multi-region location meets corporate or government data-placement policies.
  • Your persistent disk is stored in a regional location that is part of a default multi-region location. For example, your persistent disk is in the us-central1 region, so the default multi-region is us. In this case, you wish to prioritize higher snapshot availability over potentially slower snapshot restoration performance.
  • You do not expect your snapshots to be frequently restored to disks that are located outside of the default snapshot storage location.

Custom location

Select a custom location to store your snapshot in a regional location, or if you need to specify a different multi-regional location.

Some example cases for selecting a custom storage location for your snapshots are:

  • The custom multi-region location meets corporate or government data-placement policies.
  • Your application is deployed in a region that is not included in one of the Cloud Storage multi-regional locations and you wish to prioritize snapshot restoration performance over snapshot availability.
  • You restore your snapshots multiple times from a disk located outside of the default snapshot storage location.

If you need to comply with corporate or government data-placement policies, store your snapshot in the nearest regional location that complies with these policies.

If your application is not deployed in part of a multi-region and you want to prioritize low networking costs over high snapshot availability, store your snapshot in the region where your source disk is located. This will minimize networking costs for restoring and creating snapshots from that source disk.

However, unlike a multi-regional storage location, a regional storage location will not store your data redundantly across multiple data centers, so your data might not be accessible if a large-scale disruption occurs. To ensure the availability of your data, you might also want to store a redundant snapshot in a second location.

Network costs

Creating a snapshot of a source disk and creating a new disk from a snapshot can result in network costs under the following circumstances:

  • When you create a snapshot in a region that is different from the source disk's region. For example, creating a snapshot in asia-south1 from a disk in us-west1 will incur network costs as data moves from one region to the other.

  • When you create a snapshot in a multi-regional location that does not at least include the source disk's region. For example, creating a snapshot in the asia multi-regional location from a disk in us-west1 will incur network costs.

  • When you restore a snapshot to a disk in a region that is not included in the snapshot's storage location. For example, if you create a new regional persistent disk in australia-southeast1 from a snapshot stored in asia, a multi-regional location, you will incur network costs.

Creating a snapshot

In preparation for creating persistent disk snapshots, do the following:

Creating a snapshot of a zonal persistent disk

After you have prepared the disk, you can create a snapshot. Follow these steps to take a snapshot of a zonal persistent disk. If the persistent disk that you want to use is located in multiple zones, follow the instructions for creating a snapshot of a regional persistent disk.

Console

  1. Go to the Snapshots page in the Google Cloud Platform Console.
    GO TO THE SNAPSHOTS PAGE
  2. At the top of the page, click Create Snapshot.
  3. Enter a snapshot Name.
  4. Optionally, enter a Description of the snapshot.
  5. Select the Source disk from the drop-down menu.
  6. Determine your snapshot storage location. You can use the default storage location, or a custom storage location.

    1. Under Location, select whether you want to store your snapshot in a Multi-regional location or a Regional location.
    2. Select which specific region or multi-region that you want to use. To use the region or multi-region that is closest to your source disk, select Based on disk's location.
  7. Click Create to create the snapshot.

gcloud

Create your snapshot in the default storage location or in a selected storage location.

  • To create a snapshot of a zonal persistent disk in the default storage location, use the gcloud compute disks snapshot command:

    gcloud compute disks snapshot [DISK_NAME]
    

    where:

    • [DISK_NAME] is the name of the zonal persistent disk from which you want to create a snapshot.
  • Alternatively, to create a snapshot in a custom storage location, use the gcloud beta compute disks snapshot command with the storage-location flag to indicate where to store your snapshot:

    gcloud beta compute disks snapshot [DISK_NAME] --storage-location=[STORAGE_LOCATION]
    

    where:

The gcloud command-line tool waits until the operation returns a status of READY or FAILED, or reaches the maximum timeout and returns the last known details of the snapshot.

API

Create your snapshot in the default storage location or in a selected storage location.

  • To create your snapshot in the default storage location, make a POST request to the disks.createSnapshot method:

    POST https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/zones/[ZONE]/disks/[DISK_NAME]/createSnapshot
    

    where:

    • [PROJECT_ID] is your project ID.
    • [ZONE] is the zone where your instance and disk are located.
    • [DISK_NAME] is the name of the zonal persistent disk from which you want to create a snapshot.
  • Alternatively, to create a snapshot in a custom storage location, make a POST request to the disks.createSnapshot method and specify the storage location:

    POST https://www.googleapis.com/compute/v1/projects/[PROJECT_ID]/zones/[ZONE]/disks/[DISK_NAME]/createSnapshot
    
    {
      “storageLocations”: "[STORAGE_LOCATION]"
    }
    

    where:

    • [PROJECT_ID] is your project ID.
    • [ZONE] is the zone where your instance and disk are located.
    • [DISK_NAME] is the name of the zonal persistent disk from which you want to create a snapshot.
    • [STORAGE_LOCATION] is the Cloud Storage multi-region or the Cloud Storage region where you want to store your snapshot.

Create a snapshot of a regional persistent disk

After you have prepared the disk, you can create a snapshot. When creating a snapshot of a regional persistent disk, you must indicate the region where the disk is located.

Console

  1. Go to the Snapshots page in the Google Cloud Platform Console.
    GO TO THE SNAPSHOTS PAGE
  2. Enter a snapshot Name.
  3. Optionally, enter a Description of the snapshot.
  4. Under Source disk, select an existing disk from which you want to create a snapshot.
  5. Skip this step to use the default snapshot storage location. Otherwise, to use a custom storage location:

    1. Under Location, select whether you want to store your snapshot in a Multi-regional location or a Regional location.
    2. Select which specific region or multi-region that you want to use. To use the region or multi-region that is closest to your source disk, select Based on disk's location.
  6. Click Create to create the snapshot.

gcloud

Create your snapshot in the default storage location or in a selected storage location.

  • To create a snapshot of a regional persistent disk in the default storage location, use the gcloud beta compute disks snapshot command:

    gcloud beta compute disks snapshot [DISK_NAME] \
        --region [REGION]
    

    where:

    • [DISK_NAME] is the name of the regional persistent disk from which you want to create a snapshot.
    • [REGION] is the region where your regional persistent disk is located.
  • Alternatively, to create a snapshot in a custom storage location, use the gcloud beta compute disks snapshot command with the storage-location flag to indicate where to store your snapshot:

    gcloud beta compute disks snapshot [DISK_NAME] --region [REGION] \
        --storage-location [STORAGE_LOCATION]
    

    where:

    • [DISK_NAME] is the name of the regional persistent disk from which you want to create a snapshot.
    • [REGION] is the region where your regional persistent disk is located.
    • [STORAGE_LOCATION] is the Cloud Storage multi-region or the Cloud Storage region where you want to store your snapshot.

    The gcloud command-line tool waits until the operation returns a status of READY, FAILED, or reaches the maximum timeout and returns the last known details of the snapshot.

API

  • To create a snapshot in the default storage location, make a POST request to the regionDisk.createSnapshot method:

    POST https://www.googleapis.com/compute/beta/projects/[PROJECT_ID]/regions/[REGION]/disks/[DISK_NAME]/createSnapshot
    

    where:

    • [PROJECT_ID] is your project ID.
    • [REGION] is the region where your regional persistent disk is located.
    • [DISK_NAME] is the name of the disk you want to snapshot.
  • Alternatively, to create a snapshot in a custom storage location, make a POST request to the regionDisk.createSnapshot method and specify the storage location:

    POST https://www.googleapis.com/compute/beta/projects/[PROJECT_ID]/regions/[REGION]/disks/[DISK_NAME]/createSnapshot
    {
     “storageLocations”: "[STORAGE_LOCATION]"
    }
    

    where:

    • [PROJECT_ID] is your project ID.
    • [REGION] is the region where your regional persistent disk is located.
    • [DISK_NAME] is the name of the regional persistent disk from which you want to create a snapshot.
    • [STORAGE_LOCATION] is the Cloud Storage multi-region or the Cloud Storage region where you want to store your snapshot.

What's next

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

Send feedback about...

Compute Engine Documentation