Standard disk snapshots help you to periodically back up data from your Persistent Disk and Google Cloud Hyperdisk.
You can view, list, and delete disk snapshots. You can also share snapshots across projects.
Before you begin
-
If you haven't already, then set up authentication.
Authentication is
the process by which your identity is verified for access to Google Cloud services and APIs.
To run code or samples from a local development environment, you can authenticate to
Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
- Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
Required roles and permissions
To get the permissions that you need to manage standard snapshots, ask your administrator to grant you the following IAM roles on the project:
-
Compute Instance Admin (v1) (
roles/compute.instanceAdmin.v1
) -
To connect to a VM that can run as a service account:
Service Account User (v1) (
roles/iam.serviceAccountUser
)
For more information about granting roles, see Manage access to projects, folders, and organizations.
These predefined roles contain the permissions required to manage standard snapshots. To see the exact permissions that are required, expand the Required permissions section:
Required permissions
The following permissions are required to manage standard snapshots:
-
To list snapshots:
compute.snapshots.list
on the project -
To view information about a snapshot:
compute.snapshots.get
on the snapshot -
To delete a snapshot:
compute.snapshots.delete
on the snapshot -
To delete snapshots based on a filter:
-
compute.snapshots.delete
on the snapshot -
compute.snapshots.list
on the project
-
-
To share snapshot data across projects:
-
compute.storageAdmin
on the project (for accessing all standard snapshots) -
compute.disks.create
on the project to share with -
compute.snapshots.create
on the source project -
compute.disks.createSnapshot
on the source disk
-
You might also be able to get these permissions with custom roles or other predefined roles.
View the standard snapshots in a project or location
You can view or list the standard snapshots in a project or location by using the gcloud CLI, Google Cloud console, or the REST.
Console
In the Google Cloud console, go to the Snapshots page.
On the Snapshots tab, you can see the standard snapshots for the current project.
Optional. Narrow your results with the filter_list Filter field. Enter a property name or value in the Filter field, or choose from the available properties.
gcloud
To see a list of snapshots available to you in a particular project, use the
gcloud compute snapshots list
command.
gcloud compute snapshots list --project=PROJECT_ID
Optional. Replace PROJECT_ID
with the project ID.
If you omit this flag, then the current project is used. You can set the
default project for your session by using the gcloud CLI command
gcloud config set project PROJECT_ID
.
REST
To see a list of snapshots available to you in a particular project, make a
GET
request to the
snapshots.list
method.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/snapshots
Replace PROJECT_ID
with the project ID.
View the standard snapshots for a disk
You can view the list of standard snapshots for a disk by using the Google Cloud console, gcloud CLI,or REST.
Console
In the Google Cloud console, go to the Snapshots page.
On the Snapshots tab, a list of all the standard snapshots in the project appears.
Narrow the results by source disk:
Enter
Source disk:
in the filter_list Filter field, or click the Filter field and then choose the valueSource disk
from the Properties list.Select the name of the disk from the Values list that appears next to
Source disk:
in the Filter field.The snapshots displayed in the console now shows all standard snapshots for the specified disk.
If you don't see the name of a disk in the Values list, then in the Filter field next to
Source disk:
, type in the first few letters of the source disk's name to change the list of values that you see.
gcloud
List the standard snapshots for a disk with the
gcloud compute snapshots list
command
and the --filter
argument.
List the standard snapshots for a zonal disk:
gcloud compute snapshots list --filter="sourceDisk:projects/PROJECT_ID/zones/SOURCE_ZONE/disks/DISK_NAME
List the standard snapshots for a regional disk:
gcloud compute snapshots list --filter=sourceDisk:projects/PROJECT_ID/regions/SOURCE_REGION/disks/DISK_NAME
Replace the following:
PROJECT_ID
: the ID of the project.SOURCE_ZONE
: (Zonal disks only) the name of the zone for the disk, for example,us-west1-a
.SOURCE_REGION
: (Regional disks only) the name of the region for the disk, for example,us-west1
.DISK_NAME
: the name of the disk, for example,disk-1
.
REST
List the standard snapshots for a zonal or regional disk with a GET
request
to the
snapshots.list
method.
Use the filter=sourceDisk
query parameter to specify the name of the disk.
List the standard snapshots for a zonal disk:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/snapshots?filter=sourceDisk:'https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/SOURCE_ZONE/disks/DISK_NAME'
List the standard snapshots for a regional disk:
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/snapshots?filter=sourceDisk:'https://www.googleapis.com/compute/v1/projects/PROJECT_ID/regions/SOURCE_REGION/disks/DISK_NAME'
Replace the following:
PROJECT_ID
: the ID of the project.SOURCE_ZONE
: (Zonal disks only) the name of the zone for the disk, for example,us-west1-a
.SOURCE_REGION
: (Regional disks only) the name of the region for the disk, for example,us-west1
.DISK_NAME
: the name of the source disk, for exampledisk-1
.
View information about a standard snapshot
Retrieve detailed information about a standard snapshot, such as its creation time, source disk, and size by using the Google Cloud console, Google Cloud CLI, or REST.
Console
In the Google Cloud console, go to the Snapshots page.
On the Snapshots tab, view the list of snapshots in the project.
In the Name column, click the name of the standard snapshot. The Snapshot details page for the selected snapshot appears, showing its properties.
gcloud
To view information about a standard snapshot, use the
gcloud compute snapshots describe
command.
gcloud compute snapshots describe SNAPSHOT_NAME
Replace SNAPSHOT_NAME
with the name of the
standard snapshot.
REST
Make a GET
request to the
snapshots.get
method.
GET https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/snapshots/SNAPSHOT_NAME
Replace the following:
PROJECT_ID
: the name of the project containing the standard snapshot.SNAPSHOT_NAME
: the name of the standard snapshot.
Delete a snapshot
Compute Engine uses differential snapshots so that each snapshot contains only the data that has changed since the previous snapshot. 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.
To learn more about snapshot deletion, see Snapshot deletion.
Console
Go to the Snapshots page in the Google Cloud 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
Replace SNAPSHOT_NAME with the name of the snapshot that you want to delete.
Go
Java
Node.js
Python
REST
Make a DELETE
request to the
snapshots.delete
method
to delete snapshots.
DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/global/snapshots/SNAPSHOT_NAME
Replace the following:
- PROJECT_ID: the name of your project
- SNAPSHOT_NAME: the name of the snapshot to delete.
Delete multiple snapshots based on a filter
Compute Engine uses differential snapshots so that each snapshot contains only the data that has changed since the previous snapshot. Because subsequent snapshots might require information stored in a previous snapshot, deleting a snapshot does not necessarily delete all the data on the snapshot.
To learn more about snapshot deletion, see Snapshot deletion.
You can delete a number of snapshots based on a given filter. For more information on how to use filters with the gcloud CLI, see gcloud CLI topic filters.
To delete the snapshots, use a combination of the
gcloud compute snapshots list
command
with a given filter, and the
gcloud compute snapshots delete
command
with xargs
.
gcloud compute snapshots list --filter="EXPRESSION" --uri | xargs gcloud compute snapshots delete
Replace EXPRESSION
with a gcloud CLI topic
filter.
For example, --filter="creationTimestamp<'2023-12-31'"
deletes all snapshots
created before December 31, 2023.
Share snapshot data across projects in the same organization
You can use this procedure to move data from a disk in one project to a disk in a different project within the same organization.
gcloud
Create a standard snapshot in the destination project by using the
gcloud compute snapshots create
command. For example, to create a snapshot of a zonal Persistent Disk or Hyperdisk, use the following command:gcloud compute snapshots create SNAPSHOT_NAME \ --source-disk https://www.googleapis.com/compute/v1/projects/SOURCE_PROJECT_ID/zones/ZONE/disks/SOURCE_DISK_NAME \ --project DESTINATION_PROJECT_ID
Replace the following:
- SNAPSHOT_NAME: A name for the new snapshot.
- SOURCE_PROJECT_ID: The ID of the project for the source disk.
- ZONE: The zone of the source disk.
- SOURCE_DISK_NAME: The name of the source disk.
- DESTINATION_PROJECT_ID: The ID of the destination project for the new snapshot.
In the destination project, create a zonal or regional disk that's based on the snapshot by using the
gcloud compute disks create
command:gcloud compute disks create DISK_NAME \ --source-snapshot SNAPSHOT_NAME \ --project DESTINATION_PROJECT_ID
Replace the following:
- DISK_NAME: A name for the new disk.
- SNAPSHOT_NAME: The name of the snapshot.
- DESTINATION_PROJECT_ID: The ID of the destination project for the new disk.
REST
Create a standard snapshot in the destination project by calling the
snapshots.insert
method. For example, to take a snapshot of a zonal Persistent Disk or Hyperdisk, make the following request:POST https://compute.googleapis.com/compute/v1/projects/DESTINATION_PROJECT_ID/global/snapshots { "name": SNAPSHOT_NAME "sourceDisk": "projects/SOURCE_PROJECT_ID/zones/SOURCE_ZONE/disks/SOURCE_DISK_NAME }
Replace the following:
- DESTINATION_PROJECT_ID: The ID of the destination project for the new snapshot.
- SNAPSHOT_NAME: A name for the snapshot.
- SOURCE_PROJECT_ID: The ID of the source disk project.
- SOURCE_ZONE: The zone of the source disk.
- SOURCE_DISK_NAME: The name of the source disk.
In the destination project, create a zonal or regional disk that's based on the snapshot by using the zonal
disks.insert
method or the regionalregionDisks.insert
method.For example, to create a zonal disk, make the following request:
POST https://compute.googleapis.com/compute/v1/projects/DESTINATION_PROJECT_ID/zones/DESTINATION_ZONE/disks { "name": DISK_NAME "sourceSnapshot": SNAPSHOT_NAME }
Replace the following:
- DESTINATION_PROJECT_ID: The ID of the destination project for the new disk.
- DESTINATION_ZONE: The zone in the destination project for the new disk.
- DISK_NAME: A name for the new disk.
- SNAPSHOT_NAME: The name of the snapshot.
To get a list of snapshots available to you, see View the standard snapshots in a project or location.
Share a snapshot across projects in different organizations
You can use this procedure to share a standard snapshot in a project in one organization with a different project in another organization.
gcloud
In the source project, create a disk that's based on the snapshot by using the
gcloud compute disks create
command.gcloud compute disks create DISK_NAME \ --source-snapshot SNAPSHOT_NAME \ --project SOURCE_PROJECT_ID \ --zone ZONE
Replace the following:
- DISK_NAME: A name for the new disk.
- SNAPSHOT_NAME: The name of the snapshot.
- SOURCE_PROJECT_ID: The ID of the source project.
- ZONE: The zone to create the new disk in.
This disk is a temporary disk that is created only to copy the snapshot across organizations.
In the destination project, create a snapshot by using the
gcloud compute snapshots create
command.For example, to create a snapshot using the zonal disk created in the first step, use the following command:
gcloud compute snapshots create SNAPSHOT_NAME \ --source-disk https://www.googleapis.com/compute/v1/projects/SOURCE_PROJECT_ID/zones/ZONE/disks/DISK_NAME \ --project DESTINATION_PROJECT_ID
Replace the following:
- SNAPSHOT_NAME: A name for the snapshot.
- SOURCE_PROJECT_ID: The ID of the project that contains the source disk.
- ZONE: The zone of the source disk.
- DISK_NAME: The name of the disk created in step 1.
- DESTINATION_PROJECT_ID: The ID of the destination project for the new snapshot.
To get a list of snapshots available to you, see View the standard snapshots in a project or location.
Delete the temporary disk created in the first step using the
gcloud compute disks delete
command.gcloud compute disks delete DISK_NAME \ --project SOURCE_PROJECT_ID --zone ZONE
Replace the following:
- DISK_NAME: The name of the disk created in step 1.
- SOURCE_PROJECT_ID: The ID of the project that contains the source disk.
- ZONE: The zone of the disk.
REST
In the source project, create a zonal or regional disk that's based on the snapshot by using the zonal
disks.insert
method.For example, to create a zonal disk, make the following request:
POST https://compute.googleapis.com/compute/v1/projects/SOURCE_PROJECT_ID/zones/SOURCE_ZONE/disks { "name": DISK_NAME "sourceSnapshot": SNAPSHOT_NAME }
Replace the following:
- SOURCE_PROJECT_ID: The ID of the source project for the new disk.
- SOURCE_ZONE: The zone for new disk.
- DISK_NAME: A name for the new disk.
- SNAPSHOT_NAME: The name of the snapshot.
This disk is a temporary disk that is created only to copy the snapshot across organizations.
Create a snapshot in the destination project by calling the
snapshots.insert
method.For example, to create a snapshot using the zonal disk created in the first step, use the following command:
POST https://compute.googleapis.com/compute/v1/projects/DESTINATION_PROJECT_ID/global/snapshots { "name": SNAPSHOT_NAME "sourceDisk": "projects/SOURCE_PROJECT_ID/zones/SOURCE_ZONE/disks/DISK_NAME }
Replace the following:
- DESTINATION_PROJECT_ID: The ID of the destination project for the new snapshot.
- SNAPSHOT_NAME: A name for the snapshot.
- SOURCE_PROJECT_ID: The ID of the project that contains the source disk.
- SOURCE_ZONE: The zone of the source disk.
- DISK_NAME: The name of the source disk.
Delete the temporary disk created in the first step using the
disks.delete
method.DELETE https://compute.googleapis.com/compute/v1/projects/SOURCE_PROJECT_ID/zones/SOURCE_ZONE/disks/DISK_NAME
Replace the following:
- SOURCE_PROJECT_ID: The ID of the project that contains the temporary disk.
- SOURCE_ZONE: The zone of the disk.
- DISK_NAME: The name of the temporary disk created in step 1.
What's next
- Learn how to create scheduled snapshots for disks.
- Learn how to create a disk image from your snapshot.