The page guides you through how to create fine-grained restores that use filters
to target specific resources in VM and VM disk backups. You can create a restore
for a backup that was created manually or automatically by a backup plan. The
restored VMs and their associated disks have their name prefixed with the value
of the restoredResourceName field.
VM restores support fine-grained resource selection using filters. Use a filter
to restore a subset of resources from the previously created
VirtualMachineBackup resource. This filter is an optional field. If the filter
is not provided then the complete set of resources in the VirtualMachineBackup
resource are restored.
Before you begin
To create a restore, you must have the following:
- An existing backup. Create backups on a schedule using backup plans, or create backups manually. For more information, see Create a scoped backup plan.
- The necessary identity and access role. For more information, see Prepare roles and permissions.
Create a fine-grained restore
To create a fine-grained restore for a previously created backup, follow these steps:
Get a list of VMs and VM disks that were backed up in your target
VirtualMachineBackupresource:Get the list of VMs:
kubectl get VirtualMachineBackup VM_BACKUP_NAME -n VM_BACKUP_NAMESPACE -o jsonpath= "{.status.backedUpVirtualMachines}{'\n'}"Replace the following:
VM_BACKUP_NAME: the name of the backup containing the VM resources you want to restore.VM_BACKUP_NAMESPACE: the namespace containing the backup.
Get the list of VM disks:
kubectl get VirtualMachineBackup VM_BACKUP_NAME -n VM_BACKUP_NAMESPACE -o jsonpath="{.status.backedUpVirtualMachineDisks}{'\n'}"Use the values from this list to specify the target for your fine-grained restore. Create one of the following fine-grained restores:
Restore specific VMs
Use the
targetedVirtualMachinesfilter to target a list of VMs with this restore. This option restores the provided VMs and their associated disks. Create and apply aVirtualMachineRestoreRequestresource and supply your list of VMs to restore in thetargetedVirtualMachinesfield:apiVersion: virtualmachine.gdc.goog/v1 kind: VirtualMachineRestoreRequest metadata: name: RESTORE_REQUEST_NAME namespace: PROJECT_NAME spec: virtualMachineBackup: VM_BACKUP_NAME restoreName: RESTORE_NAME restoredResourceName: RESTORE_PREFIX restoredResourceDescription: RESTORED_RESOURCE_DESCRIPTION filter: targetedVirtualMachines: - resourceName: VM_NAMEReplace the following:
VM_BACKUP_NAME: the name of theVirtualMachineBackupresource to restore from.PROJECT_NAME: the name of the GDC project.RESTORE_REQUEST_NAME: the name to give the restore request that is being initiated.RESTORE_NAME: the name to give the restore that is being initiated.RESTORE_PREFIX: the prefix given to newly created VM resources. The restored VM and VM disk names are prefixed withrestoredResourceNamevalue in the restore request.RESTORED_RESOURCE_DESCRIPTION: a description of the restore being performed.VM_NAME: A list of VMs that is restored by thisVirtualMachineRestoreRequestresource. If more than one VM is specified, the list must be in the following format:targetedVirtualMachines: - resourceName: "virtual-machine" - resourceName: "virtual-machine-2" ... - resourceName: "virtual-machine-n" ```
Restore specific VM disks
Use the
targetedVirtualMachineDisksfilter to target a set of VM disks to restore. This option restores any disks that were backed up, and these disks don't have to be attached to the same VM. This option restores only the disks and not the VMs to which the disks were attached. Create and apply aVirtualMachineRestoreRequestresource and supply the list of VM disks to restore in thetargetedVirtualMachineDisksfield:apiVersion: virtualmachine.gdc.goog/v1 kind: VirtualMachineRestoreRequest metadata: name: RESTORE_REQUEST_NAME namespace: PROJECT_NAME spec: virtualMachineBackup: VM_BACKUP_NAME restoreName: RESTORE_NAME restoredResourceName: RESTORE_PREFIX restoredResourceDescription: RESTORED_RESOURCE_DESCRIPTION filter: targetedVirtualMachineDisks: - VM_DISK_NAMEReplace
VM_DISK_NAMEwith the list of VM disks that is restored by thisVirtualMachineRestoreRequestresource. If more than one VM disk is specified, the list must be in the following format:targetedVirtualMachineDisks: - resourceName: "disk-1" - resourceName: "disk-2" ... - resourceName: "disk-n"
Restore specific VMs and VM disks
To target combination of VMs and VM disks, use the
targetedVirtualMachinesandtargetedVirtualMachineDisksfilters together, this method restore the VMs specified in thetargetedVirtualMachinesfilter along with their attached disks, and the VM disks mentioned intargetedVirtualMachineDisksfilter. If the disk is already attached to the VM specified in thetargetedVirtualMachineDiskslist. In thetargetedVirtualMachineDisksfilter, specify only the disks that are not already included as part of thetargetedVirtualMachines.apiVersion: virtualmachine.gdc.goog/v1 kind: VirtualMachineRestoreRequest metadata: name: RESTORE_REQUEST_NAME namespace: PROJECT_NAME spec: virtualMachineBackup: VM_BACKUP_NAME restoreName: RESTORE_NAME restoredResourceName: RESTORE_PREFIX restoredResourceDescription: RESTORED_RESOURCE_DESCRIPTION filter: targetedVirtualMachines: - resourceName: VM_NAME targetedVirtualMachineDisks: - resourceName: VM_DISK_NAMEReplace the following:
VM_NAME:The list of VMs that is restored by thisVirtualMachineRestoreRequestresource. If more than one VM is specified, the list must be in the following format:targetedVirtualMachines: - resourceName: "virtual-machine" - resourceName: "virtual-machine-2" ... - resourceName: "virtual-machine-n" ```VM_DISK_NAME: the list of VM disks that is restored by thisVirtualMachineRestoreRequestresource. If more than one VM disk is specified, the list must be in the following format:targetedVirtualMachineDisks: - resourceName: "disk-1" - resourceName: "disk-2" ... - resourceName: "disk-n"
Restore all VM disks
Set the filter value
virtualMachineDiskOptions.allDisksto true to restore all of the disks that were protected as part ofVirtualMachineBackup. This action won't restore the VMs to which the disks were attached:apiVersion: virtualmachine.gdc.goog/v1 kind: VirtualMachineRestoreRequest metadata: name: RESTORE_REQUEST_NAME namespace: PROJECT_NAME spec: virtualMachineBackup: VM_BACKUP_NAME restoreName: RESTORE_NAME restoredResourceName: RESTORE_PREFIX restoredResourceDescription: RESTORED_RESOURCE_DESCRIPTION filter: virtualMachineDiskOptions: allDisks: true