You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/virt-restoring-vm-from-snapshot-cli.adoc
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,11 @@ You can restore an existing virtual machine (VM) to a previous configuration by
21
21
**`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.
22
22
**`WaitEventually` - The restore process waits indefinitely for the VM to be ready.
23
23
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
+
24
29
.Procedure
25
30
26
31
. 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:
37
42
kind: VirtualMachine
38
43
name: <vm_name>
39
44
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>
40
73
----
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.
0 commit comments