Back up and restore data on an instance
This page describes how to back up and restore the data on your Vertex AI Workbench instance.
Back up the data
To back up data on a Vertex AI Workbench instance, you can take a snapshot of the underlying Compute Engine virtual machine (VM) data disk.
You can create a snapshot of your instance's data disk by using the Google Cloud console, the Google Cloud CLI, or the REST API:
Console
In the Google Cloud console, go to the Instances page.
Click the instance name.
On the Instance details page, click View in Compute Engine to open VM details.
In the Additional disks section, click the name of the data disk. The name of the data disk is in this format:
INSTANCE_NAME-data-workspace
.Click Create snapshot.
In the Create a snapshot dialog, click Create.
Compute Engine creates a snapshot of the data disk.
gcloud
To create a snapshot of your instance's data disk, use the
gcloud compute snapshots create
command.
Before using any of the command data below, make the following replacements:
SNAPSHOT_NAME
: a name for your snapshotSOURCE_ZONE
: the zone where your instance is locatedINSTANCE_NAME
: the name of your instance-
STORAGE_LOCATION
: the Cloud Storage multi-region or the Cloud Storage region where you want to store your snapshot. You can specify only one storage location.
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud compute snapshots create SNAPSHOT_NAME \ --source-disk-zone=SOURCE_ZONE \ --source-disk=INSTANCE_NAME-data-workspace \ --storage-location=STORAGE_LOCATION
Windows (PowerShell)
gcloud compute snapshots create SNAPSHOT_NAME ` --source-disk-zone=SOURCE_ZONE ` --source-disk=INSTANCE_NAME-data-workspace ` --storage-location=STORAGE_LOCATION
Windows (cmd.exe)
gcloud compute snapshots create SNAPSHOT_NAME ^ --source-disk-zone=SOURCE_ZONE ^ --source-disk=INSTANCE_NAME-data-workspace ^ --storage-location=STORAGE_LOCATION
REST
To create a snapshot of your instance's data disk, make a POST
request to Compute Engine's
snapshots.insert
method.
Before using any of the request data, make the following replacements:
-
DESTINATION_PROJECT_ID
: the ID of the project where you want to create the snapshot SNAPSHOT_NAME
: a name for your snapshot-
SOURCE_PROJECT_ID
: the ID of the project where your instance is located SOURCE_ZONE
: the zone where your instance is locatedINSTANCE_NAME
: the name of your instance-
STORAGE_LOCATION
: the Cloud Storage multi-region or the Cloud Storage region where you want to store your snapshot. You can specify only one storage location.
HTTP method and URL:
POST https://compute.googleapis.com/compute/v1/projects/DESTINATION_PROJECT_ID/global/snapshots
Request JSON body:
{ "name": "SNAPSHOT_NAME", "sourceDisk": "projects/SOURCE_PROJECT_ID/zones/SOURCE_ZONE/disks/INSTANCE_NAME-data-workspace", "storageLocations": [ "STORAGE_LOCATION" ], }
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://compute.googleapis.com/compute/v1/projects/DESTINATION_PROJECT_ID/global/snapshots"
PowerShell
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://compute.googleapis.com/compute/v1/projects/DESTINATION_PROJECT_ID/global/snapshots" | Select-Object -Expand Content
Restore data from a snapshot
You can restore data on an instance by using a snapshot. When you restore data on an instance, Vertex AI Workbench deletes the existing data disk that is attached to the instance, creates a new data disk based on the snapshot, and attaches the new data disk to the instance.
You can restore data on an instance by using the gcloud CLI or the REST API:
gcloud
To restore data on an instance, use the
gcloud workbench instances restore
command.
Before using any of the command data below, make the following replacements:
INSTANCE_NAME
: the name of your instanceLOCATION
: the zone where your instance is located-
SNAPSHOT_PROJECT_NAME
: the project name where your snapshot is located SNAPSHOT_NAME
: the name of the snapshot to restore
Execute the following command:
Linux, macOS, or Cloud Shell
gcloud workbench instances restore INSTANCE_NAME \ --location=LOCATION \ --snapshot-project=SNAPSHOT_PROJECT_NAME \ --snapshot=SNAPSHOT_NAME
Windows (PowerShell)
gcloud workbench instances restore INSTANCE_NAME ` --location=LOCATION ` --snapshot-project=SNAPSHOT_PROJECT_NAME ` --snapshot=SNAPSHOT_NAME
Windows (cmd.exe)
gcloud workbench instances restore INSTANCE_NAME ^ --location=LOCATION ^ --snapshot-project=SNAPSHOT_PROJECT_NAME ^ --snapshot=SNAPSHOT_NAME
REST
To restore data on an instance, make a POST
request to the
projects.locations.instances.restore
method.
Before using any of the request data, make the following replacements:
PROJECT_ID
: your project IDLOCATION
: the zone where your instance is locatedINSTANCE_ID
: the ID of your instance-
SNAPSHOT_ID
: the ID of the snapshot to restore; to get the ID of a snapshot, use Compute Engine's snapshots.get method SNAPSHOT_PROJECT_ID
: the project ID of the snapshot
HTTP method and URL:
POST https://notebooks.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:restore
Request JSON body:
{ "snapshot": { { "snapshotId": SNAPSHOT_ID, "projectId": SNAPSHOT_PROJECT_ID } } }
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://notebooks.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:restore"
PowerShell
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://notebooks.googleapis.com/v2/projects/PROJECT_ID/locations/LOCATION/instances/INSTANCE_ID:restore" | Select-Object -Expand Content