This document describes how to manually create a backup for virtual machine (VM) workloads in Google Distributed Cloud (GDC) air-gapped.
By default, your backup plan automatically initiates scheduled backups. You can also manually create VM backups at any time, even outside of the schedule that you define. Manual VM backups let you capture a VM's state instantly and provide a recovery point independent of your scheduled backup plan.
This document is for developers in platform administrator or application operator groups that manage VM backup operations. For more information, see Audiences for GDC air-gapped documentation.
Before you begin
To create manual VM backups, you must have a single VM backup repository for backup data.
Request IAM roles
To complete the tasks in this document, request the required organization and project roles.
Organization-level roles
Ask your IAM Org Admin to
grant you the
Organization Backup Admin (organization-backup-admin) role. This role
lets you create, get, list, watch, update, patch, and delete VM backup
repositories, VM backup plan templates, VM backup requests, and VM restore
requests.
Project-level roles
Ask your IAM Project Admin to grant you the following roles:
- Virtual Machine Project Admin (
project-vm-admin): creates, gets, lists, watches, updates, patches, and deletes virtual machines and VM disks in project namespaces. - Backup Creator (
backup-creator): creates, gets, lists, watches, updates, patches, and deletes manual backup requests and manual restore requests. - Project Viewer (
project-viewer): gets, lists, and watches all resources within project namespaces.
Follow the steps to verify your access.
Create a backup plan template for VMs
You must create a backup plan template before you can trigger a manual backup. You only need to perform this step once for each backup repository. Don't create another template if you've already created one.
Console
- Sign in to the GDC console.
- In the navigation menu, click Backup for Virtual Machines > Backup plans.
- Click Create a backup plan.
- In the Project field, select the project for this backup plan.
- Enter the backup plan name and description.
- In the Backup repo field, select a backup repository. Backup repositories are a set of object storage implementations.
- Click Create.
kubectl
To plan your backups, create and apply a VirtualMachineBackupPlanTemplate
custom resource:
kubectl apply -f - <<EOF
apiVersion: virtualmachine.gdc.goog/v1
kind: VirtualMachineBackupPlanTemplate
metadata:
name: BACKUP_TEMPLATE_NAME
namespace: PROJECT_NAME
spec:
backupRepository: "BACKUP_REPOSITORY_NAME"
EOF
Replace the following:
BACKUP_TEMPLATE_NAME: the name of the backup plan template.PROJECT_NAME: the name of the project in which you want to create the template.BACKUP_REPOSITORY_NAME: the name of the backup repository you create in the previous step.
Create manual backups
Create a manual VM backup
To create a manual VM backup, create and apply a VirtualMachineBackupRequest
custom resource and specify the target of the backup using one of two methods:
Reference an existing backup plan: Use the
namespacefield in the metadata to specify the project where the plan exists, and thevirtualMachineBackupPlanfield to target the specific backup plan:kubectl apply -f - <<EOF apiVersion: virtualmachine.gdc.goog/v1 kind: VirtualMachineBackupRequest metadata: name: BACKUP_REQUEST_NAME namespace: PROJECT # Use this field if the backup plan was created using the API. spec: virtualMachineBackupPlan: VM_BACKUP_PLAN virtualMachineBackupName: VM_BACKUP_NAME deleteLockDays: DELETE_LOCK_DAYS retainDays: RETAIN_DAYS EOFUse a template and target a specific VM: Use the
virtualMachineBackupPlanTemplateandvirtualMachinefields when you define a new, immediate backup based on a template. With this method, you must specify the target VM directly in thespecsection:kubectl apply -f - <<EOF apiVersion: virtualmachine.gdc.goog/v1 kind: VirtualMachineBackupRequest metadata: name: BACKUP_REQUEST_NAME spec: virtualMachineBackupPlanTemplate: VM_BACKUP_PLAN_TEMPLATE virtualMachine: VM_NAME virtualMachineBackupName: VM_BACKUP_NAME deleteLockDays: DELETE_LOCK_DAYS retainDays: RETAIN_DAYS EOF
Replace the following:
BACKUP_REQUEST_NAME: the name for the backup request that you're initiating.PROJECT: the name of the project where the backup plan resides.VM_BACKUP_PLAN: the name of theVirtualMachineBackupPlancustom resource to target for the backup.VM_BACKUP_PLAN_TEMPLATE: the name of theVirtualMachineBackupPlanTemplatecustom resource that configures the backup.VM_NAME: the name of the VM to back up.VM_BACKUP_NAME: the name of the backup to create.DELETE_LOCK_DAYS(optional): the number of days from the creation of this backup that the system blocks backup deletion. The value must not exceed 90 days and must be less than or equal toRETAIN_DAYS. If you set this value to0, the system doesn't block deletion. If you omit this value, it defaults to the associated backup plan's configuration.RETAIN_DAYS(optional): the number of days to keep this backup before the system automatically deletes it. The value must not exceed 90 days. If you set this value to0, the system doesn't automatically delete the backup. If you omit this value, it defaults to the associated backup plan's configuration.
Create a snapshot
A snapshot captures a point-in-time image of a VM disk for restores, unlike a VM backup, which creates an independent copy of VM data in a backup repository.
Create a snapshot using either the GDC console or the API.
Console
- Sign in to the GDC console.
- In the navigation menu, click Virtual Machines > Snapshots.
- Select a project.
- Click Create snapshot.
- In the Source disk field, select the disk that you want to create the snapshot from.
- In the Snapshot name field, enter a name for the snapshot.
- Click Create.
kubectl
Create and apply a VirtualMachineBackupRequest custom resource to initiate
a snapshot:
kubectl apply -f - <<EOF
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
deleteLockDays: DELETE_LOCK_DAYS
retainDays: RETAIN_DAYS
EOF
Replace the following:
BACKUP_REQUEST_NAME: the name for the backup request that you're initiating.PROJECT_NAME: the name of the GDC project.VM_BACKUP_PLAN: the name of theVirtualMachineBackupPlanTemplatecustom resource that configures the snapshot.VM_DISK: the name of the disk that you want to snapshot.VM_BACKUP_NAME: the name of the snapshot to create.DELETE_LOCK_DAYS(optional): the number of days from the creation of this snapshot that the system blocks snapshot deletion. The value must not exceed 90 days and must be less than or equal toRETAIN_DAYS. If you set this value to0, the system doesn't block deletion. If you omit this value, it defaults to the associated backup plan's configuration.RETAIN_DAYS(optional): the number of days to keep this snapshot before the system automatically deletes it. The value must not exceed 90 days. If you set this value to0, the system doesn't automatically delete the snapshot. If you omit this value, it defaults to the associated backup plan's configuration.