Take snapshot of VM
1sudo virsh domblklist vm1
2
3Target Source
4-----------------------------------------------
5vda /var/lib/libvirt/images/vm1.img
6
7sudo virsh snapshot-create-as \
8 --domain vm1 \
9 --name guest-state1 \
10 --diskspec vda,file=/var/lib/libvirt/images/overlay1.qcow2 \
11 --disk-only \
12 --atomic \
13 --quiesceEnsure qemu-guest-agent is installed inside the VM. Otherwise omit the --quiesce flag, but when you restore the VM it will be as if the system had crashed. Not that big of a deal since the VM’s OS should flush required data and maintain consistency of its filesystems.
1sudo rsync -avhW --progress /var/lib/libvirt/images/vm1.img /var/lib/libvirt/images/vm1-copy.img
2sudo virsh blockcommit vm1 vda --active --verbose --pivotFull disk backup of VM
Start the guest VM.
1sudo virsh start vm1Enumerate the disk(s) in use.
1sudo virsh domblklist vm1
2
3Target Source
4-------------------------------------------------
5vda /var/lib/libvirt/images/vm1.qcow2Begin the backup.
1sudo virsh backup-begin vm1
2
3Backup startedCheck the job status. “None” means the job has likely completed.
1sudo virsh domjobinfo vm1
2
3Job type: NoneCheck the completed job status.
1sudo virsh domjobinfo vm1 --completed
2
3Job type: Completed
4Operation: Backup
5Time elapsed: 182 ms
6File processed: 39.250 MiB
7File remaining: 0.000 B
8File total: 39.250 MiBNow we see the copy of the backup.
1sudo ls -lash /var/lib/libvirt/images/vm1.qcow2*
2
315M -rw-r--r--. 1 qemu qemu 15M May 10 12:22 vm1.qcow2
421M -rw-------. 1 root root 21M May 10 12:23 vm1.qcow2.1620642185