Skip to content

Commit ca8a476

Browse files
Merge pull request #112910 from danielclowers/CNV-77510
CNV-77510: Document volume restore policy feature for VM snapshots
2 parents 641b90f + 91d1b67 commit ca8a476

4 files changed

Lines changed: 53 additions & 3 deletions

modules/virt-cloning-vm-web.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@ You can clone an existing VM by using the web console.
1818
Alternatively, access the same menu in the tree view by right-clicking the VM.
1919
. Select *Clone*.
2020
. On the *Clone VirtualMachine* page, enter the name of the new VM.
21-
. (Optional) Select the *Start cloned VM* checkbox to start the cloned VM.
21+
. Optional: Select the *Start cloned VM* checkbox to start the cloned VM.
22+
. Optional: In the *Volume name policy* section, select how cloned persistent volume claims (PVCs) are named:
23+
** *Randomize names* - The cloned PVC names are randomly generated. This is the default setting.
24+
** *Prefix target name* - The cloned PVC names use the target VM name as a prefix.
2225
. Click *Clone*.

modules/virt-creating-vm-from-snapshot-web.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ You can create a new VM by copying an existing snapshot.
1616
. Click the *Snapshots* tab.
1717
. Click the Options menu {kebab} for the snapshot you want to copy.
1818
. Select *Create VirtualMachine*.
19-
. Enter the name of the virtual machine.
20-
. (Optional) Select the *Start this VirtualMachine after creation* checkbox to start the new virtual machine.
19+
. Enter the name of the VM.
20+
. Optional: Select the *Start this VM after creation* checkbox to start the new VM.
21+
. Optional: In the *Volume name policy* section, select how cloned persistent volume claims (PVCs) are named:
22+
** *Randomize names* - The cloned PVC names are randomly generated. This is the default setting.
23+
** *Prefix target name* - The cloned PVC names use the target VM name as a prefix.
2124
. Click *Create*.

modules/virt-restoring-vm-from-snapshot-cli.adoc

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ You can restore an existing virtual machine (VM) to a previous configuration by
2121
** `WaitGracePeriod 5` - The restore process waits for a set amount of time, in minutes, for the VM to be ready. This is the default setting, with the default value set to 5 minutes.
2222
** `WaitEventually` - The restore process waits indefinitely for the VM to be ready.
2323
24+
* Optional: To control how restored persistent volume claims (PVCs) are named, you can set the `volumeRestorePolicy` parameter to one of the following values:
25+
** `PrefixTargetName` - The restored PVC names use the target VM name as a prefix: `<vm_name>-<volume_name>`. This is the default setting.
26+
** `RandomizeNames` - The restored PVC names are randomly generated: `restore-<uid>-<volume_name>`.
27+
** `InPlace` - The restored PVCs overwrite the original PVCs. The original PVCs are deleted if they exist, and new PVCs are created with the same names.
28+
2429
.Procedure
2530

2631
. Create a YAML file to define a `VirtualMachineRestore` object that specifies the name of the VM you want to restore and the name of the snapshot to be used as the source as in the following example:
@@ -37,7 +42,42 @@ spec:
3742
kind: VirtualMachine
3843
name: <vm_name>
3944
virtualMachineSnapshotName: <snapshot_name>
45+
volumeRestorePolicy: PrefixTargetName
46+
----
47+
+
48+
Where:
49+
+
50+
** `volumeRestorePolicy`: Optional. The volume restore policy determines how restored PVCs are named. Valid values are `PrefixTargetName` (default), `RandomizeNames`, or `InPlace`.
51+
52+
. Optional: To customize the names, labels, and annotations of individual restored persistent volume claims (PVCs), add the `volumeRestoreOverrides` parameter to the YAML file:
53+
+
54+
[source,yaml]
55+
----
56+
apiVersion: snapshot.kubevirt.io/v1beta1
57+
kind: VirtualMachineRestore
58+
metadata:
59+
name: <vm_restore>
60+
spec:
61+
target:
62+
apiGroup: kubevirt.io
63+
kind: VirtualMachine
64+
name: <vm_name>
65+
virtualMachineSnapshotName: <snapshot_name>
66+
volumeRestoreOverrides:
67+
- volumeName: <volume_name>
68+
restoreName: <custom_pvc_name>
69+
labels:
70+
custom-label: <label_value>
71+
annotations:
72+
custom-annotation: <annotation_value>
4073
----
74+
+
75+
Where:
76+
+
77+
** `volumeName`: Required. The name of the volume from the snapshot to customize.
78+
** `restoreName`: Optional. The custom name for the restored PVC. If not specified, the PVC name is determined by the `volumeRestorePolicy` setting.
79+
** `labels`: Optional. Custom labels to add to the restored PVC. These labels are merged with any existing labels from the source PVC.
80+
** `annotations`: Optional. Custom annotations to add to the restored PVC. These annotations are merged with any existing annotations from the source PVC.
4181

4282
. Create the `VirtualMachineRestore` object:
4383
+

modules/virt-restoring-vm-from-snapshot-web.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ You can restore a virtual machine (VM) to a previous configuration represented b
1717
. Click the *Snapshots* tab to view a list of snapshots associated with the VM.
1818
. Select a snapshot to open the *Snapshot Details* screen.
1919
. Click the Options menu {kebab} and select *Restore VirtualMachine from snapshot*.
20+
. Optional: In the *Volume restore policy* section, select how restored persistent volume claims (PVCs) are named:
21+
** *Prefix target name* - The restored PVC names use the target VM name as a prefix. This is the default setting.
22+
** *In place* - The restored PVCs overwrite the original PVCs with the same names.
23+
** *Randomize names* - The restored PVC names are randomly generated.
2024
. Click *Restore*.
2125

2226
. Optional: You can also create a new VM based on the snapshot. To do so:

0 commit comments

Comments
 (0)