Skip to content

Commit 79906cf

Browse files
authored
Merge pull request #86693 from shdeshpa07/OADP-5013-kubevirt-vm-label
OADP backup-restore single VM
2 parents b490b7c + ee7fbd8 commit 79906cf

File tree

4 files changed

+151
-0
lines changed

4 files changed

+151
-0
lines changed

backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ include::modules/install-and-configure-oadp-kubevirt.adoc[leveloffset=+1]
4444

4545
include::modules/oadp-installing-dpa-1-3.adoc[leveloffset=+1]
4646
include::snippets/oadp-windows-vm-backup-fails.adoc[]
47+
include::modules/oadp-backup-single-vm.adoc[leveloffset=+1]
48+
include::modules/oadp-restore-single-vm.adoc[leveloffset=+1]
49+
include::modules/oadp-restore-single-vm-from-multiple-vm-backup.adoc[leveloffset=+1]
4750
include::modules/oadp-configuring-client-burst-qps.adoc[leveloffset=+1]
4851
include::modules/oadp-configuring-node-agents.adoc[leveloffset=+2]
4952
include::modules/oadp-incremental-backup-support.adoc[leveloffset=+1]

modules/oadp-backup-single-vm.adoc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc
4+
5+
6+
:_mod-docs-content-type: PROCEDURE
7+
[id="oadp-backup-single-vm_{context}"]
8+
= Backing up a single VM
9+
10+
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.
11+
12+
13+
.Prerequisites
14+
15+
* You have installed the {oadp-short} Operator.
16+
* You have multiple VMs running in a namespace.
17+
* You have added the `kubevirt` plugin in the `DataProtectionApplication` (DPA) custom resource (CR).
18+
* You have configured the `BackupStorageLocation` CR in the `DataProtectionApplication` CR and `BackupStorageLocation` is available.
19+
20+
.Procedure
21+
22+
. Configure the `Backup` CR as shown in the following example:
23+
+
24+
.Example `Backup` CR
25+
[source,yaml]
26+
----
27+
apiVersion: velero.io/v1
28+
kind: Backup
29+
metadata:
30+
name: vmbackupsingle
31+
namespace: openshift-adp
32+
spec:
33+
snapshotMoveData: true
34+
includedNamespaces:
35+
- <vm_namespace> # <1>
36+
labelSelector:
37+
matchLabels:
38+
app: <vm_app_name> # <2>
39+
storageLocation: <backup_storage_location_name> # <3>
40+
----
41+
<1> Specify the name of the namespace where you have created the VMs.
42+
<2> Specify the VM name that needs to be backed up.
43+
<3> Specify the name of the `BackupStorageLocation` CR.
44+
45+
. To create a `Backup` CR, run the following command:
46+
+
47+
[source, terminal]
48+
----
49+
$ oc apply -f <backup_cr_file_name> # <1>
50+
----
51+
<1> Specify the name of the `Backup` CR file.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc
4+
5+
6+
:_mod-docs-content-type: PROCEDURE
7+
[id="oadp-restore-single-vm-from-multiple-vm-backup_{context}"]
8+
= Restoring a single VM from a backup of multiple VMs
9+
10+
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: <vm_name>` and the `kubevirt.io/created-by` labels. To match the `kubevirt.io/created-by` label, use the UID of `DataVolume` of the VM.
11+
12+
13+
.Prerequisites
14+
15+
* You have installed the {oadp-short} Operator.
16+
* You have labeled the VMs that need to be backed up.
17+
* You have a backup of multiple VMs.
18+
19+
.Procedure
20+
21+
. Before you take a backup of many VMs, ensure that the VMs are labeled by running the following command:
22+
+
23+
[source, terminal]
24+
----
25+
$ oc label vm <vm_name> app=<vm_name> -n openshift-adp
26+
----
27+
28+
. Configure the label selectors in the `Restore` CR as shown in the following example:
29+
+
30+
.Example `Restore` CR
31+
[source,yaml]
32+
----
33+
apiVersion: velero.io/v1
34+
kind: Restore
35+
metadata:
36+
name: singlevmrestore
37+
namespace: openshift-adp
38+
spec:
39+
backupName: multiplevmbackup
40+
restorePVs: true
41+
LabelSelectors:
42+
- matchLabels:
43+
kubevirt.io/created-by: <datavolume_uid> # <1>
44+
- matchLabels:
45+
app: <vm_name> # <2>
46+
----
47+
<1> Specify the UID of `DataVolume` of the VM that you want to restore. For example, `b6...53a-ddd7-4d9d-9407-a0c...e5`.
48+
<2> Specify the name of the VM that you want to restore. For example, `test-vm`.
49+
50+
. To restore a VM, run the following command:
51+
+
52+
[source, terminal]
53+
----
54+
$ oc apply -f <restore_cr_file_name> # <1>
55+
----
56+
<1> Specify the name of the `Restore` CR file.

modules/oadp-restore-single-vm.adoc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * backup_and_restore/application_backup_and_restore/installing/installing-oadp-kubevirt.adoc
4+
5+
6+
:_mod-docs-content-type: PROCEDURE
7+
[id="oadp-restore-single-vm_{context}"]
8+
= Restoring a single VM
9+
10+
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.
11+
12+
.Prerequisites
13+
14+
* You have installed the {oadp-short} Operator.
15+
* You have backed up a single VM by using the label selector.
16+
17+
.Procedure
18+
19+
. Configure the `Restore` CR as shown in the following example:
20+
+
21+
.Example `Restore` CR
22+
[source,yaml]
23+
----
24+
apiVersion: velero.io/v1
25+
kind: Restore
26+
metadata:
27+
name: vmrestoresingle
28+
namespace: openshift-adp
29+
spec:
30+
backupName: vmbackupsingle # <1>
31+
restorePVs: true
32+
----
33+
<1> Specifies the name of the backup of a single VM.
34+
35+
. To restore the single VM, run the following command:
36+
+
37+
[source, terminal]
38+
----
39+
$ oc apply -f <restore_cr_file_name> # <1>
40+
----
41+
<1> Specify the name of the `Restore` CR file.

0 commit comments

Comments
 (0)