Back up disks

Back up your disks regularly to ensure that your snapshot data is relatively current, and to reduce the risk of unexpected data loss when carrying out data backup and recovery operations.

Create snapshots

Create snapshots to periodically back up data from your persistent disks.

Before you begin

Ensure that a user with the Backup Repository Admin role created the following items:

To get the permissions that you need to create a snapshot, ask your Project IAM Admin to grant you the following roles:

  • Project VM Admin (project-vm-admin)
  • Backup Creator: (backup-creator)
  • Project Viewer: (project-viewer)

Create a snapshot

Create a snapshot using either the GDC console or the API.

Console

  1. Sign in to the GDC console.
  2. In the navigation menu, click Virtual Machines > Snapshots.
  3. Select a project.
  4. Click Create snapshot.
  5. In the Source disk field, select the disk that you want to create the snapshot from.
  6. Enter the Snapshot name.
  7. Click Create.

API

Issue a VirtualMachineBackupRequest to initiate a snapshot:

apiVersion: virtualmachine.gdc.goog/v1
kind: VirtualMachineBackupRequest
metadata:
  name: BACKUP_REQUEST_NAME
  namespace: PROJECT_NAME
spec:
  virtualMachineBackupPlanTemplate: VM_BACKUP_PLAN
  virtualMachineDisk: VM_DISK
  virtualMachineBackupName: VM_BACKUP_NAME

Replace the following:

  • BACKUP_REQUEST_NAME: the name to give the backup request that is being initiated.
  • PROJECT_NAME: the name of the GDC project.
  • VM_BACKUP_PLAN: the name of the VirtualMachineBackupPlanTemplate to use for configuration of the snapshot. For snapshots, this value is disk-snapshot-bpt.
  • VM_DISK: the name of the disk to snapshot.
  • VM_BACKUP_NAME: the name of the snapshot to create.

View snapshots

View snapshots and their details by using the Google Cloud console or kubectl.

Console

  1. Sign in to the GDC console.
  2. In the navigation menu, click Virtual Machines > Snapshots.
  3. Select a project.
  4. In the list of snapshots, click the snapshot name to view its details.

kubectl

View a snapshot by listing the snapshots and viewing their details.

  1. List the existing snapshots:

    kubectl get virtualmachinebackups.virtualmachine.gdc.goog -n PROJECT_NAME
    

    Replace PROJECT_NAME with the name of the project.

  2. In the list, find the snapshot that you want to view.

  3. View the snapshot details:

    kubectl describe virtualmachinebackup.virtualmachine.gdc.goog VM_BACKUP_NAME -n PROJECT_NAME
    

    Replace the following:

    • VM_BACKUP_NAME: the name of the snapshot.
    • PROJECT_NAME: the name of the project.

Delete a snapshot

Delete snapshots by using the Google Cloud console or kubectl. Disks created from snapshots are not affected when the underlying snapshot is deleted.

Console

  1. Sign in to the GDC console.
  2. In the navigation menu, click Virtual Machines > Snapshots.
  3. Select a project.
  4. In the list of snapshots, find the snapshot to delete and click Delete.
  5. Click Confirm.

kubectl

Delete a snapshot using kubectl.

  1. List the existing snapshots:

    kubectl get virtualmachinebackups.virtualmachine.gdc.goog -n PROJECT_NAME
    

    Replace PROJECT_NAME with the name of the project.

  2. In the list, find the snapshot that you want to delete.

  3. Issue a VirtualMachineDeleteBackupRequest to delete the snapshot:

    apiVersion: virtualmachine.gdc.goog/v1
    kind: VirtualMachineDeleteBackupRequest
    metadata:
      name: DELETE_BACKUP_REQUEST_NAME
      namespace: PROJECT_NAME
    spec:
      virtualMachineBackupRef:
        name: VM_BACKUP_NAME
    

    Replace the following:

    • DELETE_BACKUP_REQUEST_NAME: name to give the delete backup request that is being initiated.
    • VM_BACKUP_NAME: the name of the snapshot to delete.
    • PROJECT_NAME: the name of the project.

What's next

You can restore a VM disk from an image disk snapshot. For more information, see Restore a VM from a snapshot.