Backup rules for VMs
File-system consistent backups require you to freeze IO operations before backing up the volumes and unfreeze them after creation of backups. If you want to take file-system consistent backups, here are the sample values for pod selector and action field to create pre-exec and post-exec rules.
Refer Create Backup Rules to create pre-exec and post-exec rules for the VMs.
Action field can be fetched from Virtlauncher pod.
Here is a sample Pod Selector and Action values for pre-exec and post exec rules:
Pre-exec rule values for freeze
- Pod Selector:
vm.kubevirt.io/name: “<vm-name>”
- Action:
/usr/bin/virt-freezer --freeze --name <vm-name> --namespace <namespace>
- Pod Selector:
Post-exec rule values for unfreeze/thaw
- Pod Selector:
vm.kubevirt.io/name: “<vm-name>”
- Action:
/usr/bin/virt-freezer --unfreeze --name <vm-name> --namespace <namespace>
The action for freeze/unfreeze can be fetched by describing the virt-launcher pod of the VM.
noteFor every VM that you want to backup, make sure there exists a pod-selector and action specific to the VM in the pre-exec and post-exec rules.
Following illustration provides sample freeze and unfreeze pre-exec rule for a VM:
- Pod Selector:
KDMP Backup and Restore with KubeVirt VMs
Consider a cluster running OpenShift 4.11 and above with KubeVirt 0.59.x. Let us assume that your KubeVirt VMs use PVCs with ReadWriteOnce (RWO) volumes and are in running state. In this environment, when the user takes a generic backup (that triggers KDMP backup), backup and restore operations complete successfully but the KubeVirt VMs state goes to indefinite paused state.
KDMP backups are not supported in SELinux enabled OpenShift environments.
To avoid encountering this scenario or as a workaround, make sure that you:
Refrain from taking generic backups of KubeVirt VMs that are in running state that use RWO volumes.
Restart the VMs in paused state using
virtctl
CLI or Openshift web console if KubeVirt VMs go to paused state due to the backup process, after the backup is successful.Use Portworx volumes as RWO which does not use generic backup.
Set access mode for non-portworx provisioner volumes as ReadWriteMany (RWX) or ReadOnlyMany (ROX).