To access data captured in an instant snapshot, you must create a new disk from the instant snapshot.
This page explains how to create a disk from an instant snapshot. After you create the disk, you can use it by attaching it to a virtual machine (VM).
Before you begin
-
Set up authentication.
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
-
Restrictions
The following restrictions apply:
- When you create a disk from an instant snapshot, the new disk always has the same type and storage location as the source disk of the snapshot.
- A disk created from an instant snapshot can be used as a boot disk only if the source disk for the snapshot was also a boot disk.
- You can't create a VM directly from an instant snapshot.
Create a new disk from an instant snapshot
Create a new disk containing the data captured in an instant snapshot.
You can create a new regional or zonal disk from an instant snapshot, depending on the type of the snapshot. The new disk inherits its location and type from the source disk.
Console
When you create a disk from an instant snapshot in the console, you don't have to specify the disk's location.
Find the instant snapshot that you want to restore:
In the Google Cloud console, go to the Snapshots page.
Click the Instant snapshots tab.
In the Name column, click the name of the instant snapshot you want to restore.
Click Create disk.
In the Name field, enter a new name for the disk.
Optional: Enter additional details in the Description field.
Verify that the Disk source type is Instant snapshot.
In the Source instant snapshot list, choose the instant snapshot.
Optional: Configure additional customizations for the disk.
- Enter a size: In the Size field, specify a size for the disk in gigabytes. The size must be equal to or larger than the size of the source disk for the snapshot.
- Schedule backups: If you want Compute Engine to create standard snapshots of this new disk on a schedule, select the Enable snapshot schedule checkbox and choose a snapshot schedule. Otherwise, clear the checkbox.
- Add labels: To organize your project, add one or more labels.
Click Create to create the disk.
gcloud
-
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
Use the
gcloud beta compute disks create
command. The arguments you specify depend on whether you're creating a zonal or regional disk.Create a zonal disk:
Specify the zone with the
--zone
flag and the source instant snapshot with the--source-instant-snapshot
flag.gcloud beta compute disks create DISK_NAME --zone=ZONE \ --source-instant-snapshot=SOURCE_INSTANT_SNAPSHOT_NAME
Replace the following:
DISK_NAME
: the name of the new disk.ZONE
: the zone for the new disk, for example,europe-west1-a
.SOURCE_INSTANT_SNAPSHOT_NAME
: the name of the source instant snapshot
Create a regional disk:
Specify the region with
--region
and the source instant snapshot with--source-instant-snapshot
.gcloud beta compute disks create DISK_NAME \ --region=REGION \ --source-instant-snapshot=SOURCE_INSTANT_SNAPSHOT_NAME \ --replica-zones=ZONE1,ZONE2
Replace the following:
DISK_NAME
: the name of the new disk.REGION
: the region for the regional disk to reside in, for example:europe-west1
.SOURCE_INSTANT_SNAPSHOT_NAME
: the name of the source instant snapshot.ZONE1,ZONE2
: the zones within the region where the two disk replicas are located, for example:europe-west1-b,europe-west1-c
.
REST
To create a zonal or regional disk from an instant snapshot, use the disks.insert method. The new disk must be the same type as that of the source disk of the instant snapshot. For example, you can't create a regional disk from a snapshot of a zonal disk.
Create a zonal disk:
Make a
POST
request, specifying the source instant snapshot.POST https://compute.googleapis.com/compute/beta/projects/PROJECT/zones/SOURCE_ZONE/disks { "name": "NEW_DISK_NAME", "sourceInstantSnapshot": "projects/PROJECT/zones/SOURCE_ZONE/instantSnapshots/SOURCE_INSTANT_SNAPSHOT_NAME", "diskEncryptionKey": { "DISK_ENCRYPTION_KEY" } }
Replace the following with the corresponding values:
PROJECT
: the project in which to create the new disk.SOURCE_ZONE
: the zone where the instant snapshot is located, for example,us-central1-a
. The disk is created in this zone.NEW_DISK_NAME
: a unique name for the new disk.SOURCE_INSTANT_SNAPSHOT_NAME
: the name of the source instant snapshot.DISK_ENCRYPTION_KEY
: the key to use to encrypt the new disk. See an example of the format.
Create a regional disk:
Make a
POST
request, specifying the source instant snapshot and the zones where the disk should be replicated to.POST https://compute.googleapis.com/compute/beta/projects/PROJECT/region/SOURCE_REGION/disks { "name": "NEW_DISK_NAME", "sourceInstantSnapshot": "projects/PROJECT/regions/SOURCE_REGION/instantSnapshots/SOURCE_INSTANT_SNAPSHOT_NAME", "replicaZones": [ "projects/PROJECT/zones/ZONE1", "projects/PROJECT/zones/ZONE2" ], "diskEncryptionKey": { "DISK_ENCRYPTION_KEY" } }
Replace the following with the corresponding values:
PROJECT
: the project in which to create the new disk.SOURCE_REGION
: the region where the instant snapshot is located. The disk is created in this region.NEW_DISK_NAME
: a unique name for the new disk.DISK_ENCRYPTION_KEY
: the key to use to encrypt the new disk.SOURCE_INSTANT_SNAPSHOT_NAME
: the name of the source instant snapshot.ZONE1,ZONE2
: the zones within the region where the two disk replicas are located, for example:europe-west1-b
,europe-west1-c
.
API request response
If the POST
request is successful, the response body will be an object that you can poll to get the status of the disk's creation. See
Handling API responses
for more information.