Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Qemu

Take snapshot of VM

sudo virsh domblklist vm1

sudo virsh snapshot-create-as \
    --domain vm1 \
    --name guest-state1 \
    --diskspec vda,file=/var/lib/libvirt/images/overlay1.qcow2 \
    --disk-only \
    --atomic \
    --quiesce

Ensure 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 filesystem.

sudo rsync -avhW --progress /var/lib/libvirt/images/vm1.img /var/lib/libvirt/images/vm1-copy.img
sudo virsh blockcommit vm1 vda --active --verbose --pivot

Full disk backup of VM

Start the guest VM.

sudo virsh start vm1

Enumerate the disk(s) in use.

sudo virsh domblklist vm1

Begin the backup.

sudo virsh backup-begin vm1

Check the job status. “None” means the job has likely completed.

sudo virsh domjobinfo vm1

Check the completed job status.

sudo virsh domjobinfo vm1 --completed

Now we see the copy of the backup.

sudo ls -lash /var/lib/libvirt/images/vm1.qcow2*