From f76aaa6a232f7c89b9a5316229eda2942ac9770e Mon Sep 17 00:00:00 2001 From: Shruti Deshpande Date: Mon, 6 Jan 2025 10:14:56 +0530 Subject: [PATCH] OADP backup single VM Signed-off-by: Shruti Deshpande --- .../installing/installing-oadp-kubevirt.adoc | 3 + modules/oadp-backup-single-vm.adoc | 51 +++++++++++++++++ ...ore-single-vm-from-multiple-vm-backup.adoc | 56 +++++++++++++++++++ modules/oadp-restore-single-vm.adoc | 41 ++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 modules/oadp-backup-single-vm.adoc create mode 100644 modules/oadp-restore-single-vm-from-multiple-vm-backup.adoc create mode 100644 modules/oadp-restore-single-vm.adoc diff --git a/backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc b/backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc index 55051bfd86..88dcb8a74a 100644 --- a/backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc +++ b/backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc @@ -44,6 +44,9 @@ include::modules/install-and-configure-oadp-kubevirt.adoc[leveloffset=+1] include::modules/oadp-installing-dpa-1-3.adoc[leveloffset=+1] include::snippets/oadp-windows-vm-backup-fails.adoc[] +include::modules/oadp-backup-single-vm.adoc[leveloffset=+1] +include::modules/oadp-restore-single-vm.adoc[leveloffset=+1] +include::modules/oadp-restore-single-vm-from-multiple-vm-backup.adoc[leveloffset=+1] include::modules/oadp-configuring-client-burst-qps.adoc[leveloffset=+1] include::modules/oadp-configuring-node-agents.adoc[leveloffset=+2] include::modules/oadp-incremental-backup-support.adoc[leveloffset=+1] diff --git a/modules/oadp-backup-single-vm.adoc b/modules/oadp-backup-single-vm.adoc new file mode 100644 index 0000000000..d8f074bb9c --- /dev/null +++ b/modules/oadp-backup-single-vm.adoc @@ -0,0 +1,51 @@ +// Module included in the following assemblies: +// +// * backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc + + +:_mod-docs-content-type: PROCEDURE +[id="oadp-backup-single-vm_{context}"] += Backing up a single VM + +If you have a namespace with multiple virtual machines (VMs), and want to back up only one of them, you can use the label selector to filter the VM that needs to be included in the backup. You can filter the VM by using the `app: vmname` label. + + +.Prerequisites + +* You have installed the {oadp-short} Operator. +* You have multiple VMs running in a namespace. +* You have added the `kubevirt` plugin in the `DataProtectionApplication` (DPA) custom resource (CR). +* You have configured the `BackupStorageLocation` CR in the `DataProtectionApplication` CR and `BackupStorageLocation` is available. + +.Procedure + +. Configure the `Backup` CR as shown in the following example: ++ +.Example `Backup` CR +[source,yaml] +---- +apiVersion: velero.io/v1 +kind: Backup +metadata: + name: vmbackupsingle + namespace: openshift-adp +spec: + snapshotMoveData: true + includedNamespaces: + - # <1> + labelSelector: + matchLabels: + app: # <2> + storageLocation: # <3> +---- +<1> Specify the name of the namespace where you have created the VMs. +<2> Specify the VM name that needs to be backed up. +<3> Specify the name of the `BackupStorageLocation` CR. + +. To create a `Backup` CR, run the following command: ++ +[source, terminal] +---- +$ oc apply -f # <1> +---- +<1> Specify the name of the `Backup` CR file. \ No newline at end of file diff --git a/modules/oadp-restore-single-vm-from-multiple-vm-backup.adoc b/modules/oadp-restore-single-vm-from-multiple-vm-backup.adoc new file mode 100644 index 0000000000..a003482990 --- /dev/null +++ b/modules/oadp-restore-single-vm-from-multiple-vm-backup.adoc @@ -0,0 +1,56 @@ +// Module included in the following assemblies: +// +// * backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc + + +:_mod-docs-content-type: PROCEDURE +[id="oadp-restore-single-vm-from-multiple-vm-backup_{context}"] += Restoring a single VM from a backup of multiple VMs + +If you have a backup containing multiple virtual machines (VMs), and you want to restore only one VM, you can use the `LabelSelectors` section in the `Restore` CR to select the VM to restore. To ensure that the persistent volume claim (PVC) attached to the VM is correctly restored, and the restored VM is not stuck in a `Provisioning` status, use both the `app: ` and the `kubevirt.io/created-by` labels. To match the `kubevirt.io/created-by` label, use the UID of `DataVolume` of the VM. + + +.Prerequisites + +* You have installed the {oadp-short} Operator. +* You have labeled the VMs that need to be backed up. +* You have a backup of multiple VMs. + +.Procedure + +. Before you take a backup of many VMs, ensure that the VMs are labeled by running the following command: ++ +[source, terminal] +---- +$ oc label vm app= -n openshift-adp +---- + +. Configure the label selectors in the `Restore` CR as shown in the following example: ++ +.Example `Restore` CR +[source,yaml] +---- +apiVersion: velero.io/v1 +kind: Restore +metadata: + name: singlevmrestore + namespace: openshift-adp +spec: + backupName: multiplevmbackup + restorePVs: true + LabelSelectors: + - matchLabels: + kubevirt.io/created-by: # <1> + - matchLabels: + app: # <2> +---- +<1> Specify the UID of `DataVolume` of the VM that you want to restore. For example, `b6...53a-ddd7-4d9d-9407-a0c...e5`. +<2> Specify the name of the VM that you want to restore. For example, `test-vm`. + +. To restore a VM, run the following command: ++ +[source, terminal] +---- +$ oc apply -f # <1> +---- +<1> Specify the name of the `Restore` CR file. \ No newline at end of file diff --git a/modules/oadp-restore-single-vm.adoc b/modules/oadp-restore-single-vm.adoc new file mode 100644 index 0000000000..83b11fa2e2 --- /dev/null +++ b/modules/oadp-restore-single-vm.adoc @@ -0,0 +1,41 @@ +// Module included in the following assemblies: +// +// * backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc + + +:_mod-docs-content-type: PROCEDURE +[id="oadp-restore-single-vm_{context}"] += Restoring a single VM + +After you have backed up a single virtual machine (VM) by using the label selector in the `Backup` custom resource (CR), you can create a `Restore` CR and point it to the backup. This restore operation restores a single VM. + +.Prerequisites + +* You have installed the {oadp-short} Operator. +* You have backed up a single VM by using the label selector. + +.Procedure + +. Configure the `Restore` CR as shown in the following example: ++ +.Example `Restore` CR +[source,yaml] +---- +apiVersion: velero.io/v1 +kind: Restore +metadata: + name: vmrestoresingle + namespace: openshift-adp +spec: + backupName: vmbackupsingle # <1> + restorePVs: true +---- +<1> Specifies the name of the backup of a single VM. + +. To restore the single VM, run the following command: ++ +[source, terminal] +---- +$ oc apply -f # <1> +---- +<1> Specify the name of the `Restore` CR file. \ No newline at end of file