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

Selecting your snapshot storage location is vital to minimizing network costs. If you store your snapshot in the same region as your source disk there is no network charge when you access that snapshot from the same region. If you access the snapshot from a different region, there is a network cost.

If your source disk's geographic storage location is the same as its multi-region, there is no network charge.

For example, if your source disk is in asia-east1-a you can store your snapshot in the asia-east1 region or the asia multi-region. You will not incur a network cost when you access your snapshots.

There is a network charge for cross-region access. For example, if your source disk is in asia-east1 and you store your snapshots in asia-east2, you will incur a network cost when you access your snapshot between those two regions.

Two regions, australia-southeast1 and southamerica-east1, have a default multi-region snapshot storage location that will incur network costs unless you override the default when creating a snapshot.

  • If your source disk is in australia-southeast1, the default snapshot storage location is in the asia multi-region. To reduce costs, override this default location and store your snapshots in the australia-southeast1 region.
  • If your source disk is in southamerica-east1, the default snapshot storage location is in the us multi-region. To reduce costs, override this default location and store your snapshots in the southamerica-east1 region.

If you restore a snapshot to a disk in a region that is not included in the snapshot's storage location you will incur a network cost. 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 Create a Snapshot page in the Google Cloud Platform Console.
    go to the create a snapshot page
  2. Enter a snapshot Name.
  3. Optionally, enter a Description of the snapshot.
  4. Select the Source disk from the drop-down menu.
  5. 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 (default).
  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 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 --storage-location flag to indicate where to store your snapshot:

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

    where:

    • [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. You can specify only one storage location.

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. You can specify only one storage location.

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. Optionally, you can specify 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 compute disks snapshot command:

    gcloud 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.
  • Optionally, you can specify a custom storage location:

    gcloud 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. You can specify only one storage location.

    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/v1/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/v1/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. You can specify only one storage location.

What's next

Σας βοήθησε αυτή η σελίδα; Πείτε μας τη γνώμη σας:

Αποστολή σχολίων σχετικά με…

Αυτή η σελίδα
Compute Engine Documentation