Backup and Recovery for Virtual Machines

Introduction

Data Protection is a major topic of conversation when it comes to any enterprise workload, and there are no shortage of options currently available for backup and recovery of virtual machines with OpenShift Virtualization. Many of these solutions function in the same manner at which they protect pods in OpenShift. They do this by taking a backup of the virtual machine, or a namespace containing multiple virtual machines and store it remotely in an object storage bucket. These backups usually also include the persistent storage volume, alongside the metadata and custom resources that define the virtual machine.

Red Hat Solutions Include:

Ecosystem Partner Solutions Include:

This is not intended to be an exhaustive list of partners offering a supported backup and recovery solution. Please check with your storage or data protection vendor(s) to determine the compatibility of their product with OpenShift Virtualization.

In this portion of the lab, we will use OADP to perform a virtual machine backup and restore.

Review the OADP Operator

  1. Navigate in the left menu to OperatorsInstalled Operators and ensure that project oadp-{user} is selected. Type OADP in the Name search field and you should be presented with the installed version of the OADP Operator. Click on the operator to see it’s details.

    00 Left Menu
  2. Review the Provided APIs available. In this module, the Backup and Restore functions will be used.

    01 Overview
  3. Use the horizontal scrollbar at the top to navigate to the tab DataProtectionApplication. This object represents the configuration of the deployed OADP instance.

    02 DPA
  4. Click on oadp-dpa to see the details of the DataProtectionApplication and then click on the YAML button at the top to see how it is configured.

    03 OADP YAML

    Notice that OADP has been configured by adding the kubevirt plugin and it has been configured to use the internal object storage bucket provided by OpenShift Data Foundations running on your cluster.

    For the sake of convenience our lab is setup to perform the backups to a local object bucket, however in a production environment you would want to ensure that backups are directed to an external storage system, or a cloud-based object storage bucket.

Create a Virtual Machine Backup

You now will perform a backup of the VM fedora02 which we created in the previous section. The selection of the objects to be backed up is defined by the labels app and vm.kubevirt.io/name. This includes the VM definition, disks, and additional objects being used by the virtual machine such as config maps and secrets.

  1. Navigate back to the Operator details and using the horizontal scrollbar, scroll back until you see the Backup tab.

  2. Click on the Backup tab and press the Create Backup button.

    04 Backup Tab
  3. Switch to the YAML view and replace the default content with the following one:

    ---
    apiVersion: velero.io/v1
    kind: Backup
    metadata:
      name: backup-fedora02
      namespace: oadp-{user}
      labels:
        velero.io/storage-location: default
    spec:
      defaultVolumesToFsBackup: false
      orLabelSelectors:
      - matchLabels:
          app: fedora02
      - matchLabels:
          vm.kubevirt.io/name: fedora02
      csiSnapshotTimeout: 10m0s
      ttl: 720h0m0s
      itemOperationTimeout: 4h0m0s
      storageLocation: oadp-dpa-1
      hooks: {}
      includedNamespaces:
      - vmexamples-{user}
      snapshotMoveData: false
  4. Click the Create button at the bottom.

    Note that the content of this YAML indicates that any object with the labels app: fedora02 in the namespace vmexamples-{user} will be backed up to the location specified in the DataProtectionApplication configuration.

    05 Create Backup YAML
    If you did not complete the previous section, and you do not have the fedora02 VM, change the label selectors in the YAML above to match a virtual machine in your inventory.
  5. Wait until the Status column changes to Completed. This indicates that the virtual machine has been successfully backed up.

    06 Backup Completed

Restore From a Backup

  1. Navigate to VirtualizationVirtualMachines, click on the three-dot menu to the right of the fedora02 VM and select Delete from the menu that appears (you may need to switch back to the vmexamples-{user} project).

    07 Delete VM
  2. When prompted, click the red Delete button to confirm deleting the virtual machine.

    08 Confirm Delete
  3. Go back to OperatorsInstalled Operators and select OADP Operator (you may need to switch back to the oadp-{user} project).

  4. Use the horizontal navigation bar to locate the the Restore tab, click the Restore tab, and then press Create Restore.

    09 Restore Tab
  5. Switch to the YAML view and replace the content with the following one:

    ---
    apiVersion: velero.io/v1
    kind: Restore
    metadata:
      name: restore-fedora02
      namespace: oadp-{user}
    spec:
      backupName: backup-fedora02
      includedResources: []
      excludedResources:
      - nodes
      - events
      - events.events.k8s.io
      - backups.velero.io
      - restores.velero.io
      restorePVs: true
  6. Press the Create button at the bottom.

    10 Create Restore YAML
  7. Wait until you see that the Status column changes to Completed.

    11 Restore Completed
  8. Navigate back to VirtualizationVirtual Machines and confirm that the fedora02 virtual machine was restored (in the vmexamples-{user} project).

    12 VM Restored

Summary

Protecting virtual machines is a critical aspect of a virtualization platform. OpenShift Virtualization provides multiple methods that enable native protection, for example using OADP, or allowing storage and backup partners to integrate their offerings. If you have questions about how to protect virtual machines, please don’t hesitate to ask the proctors for the workshop or reach out to your vendor to determine their compatibility with OpenShift Virtualization.