KVM – Live backups with qcow2

List the current block device in use:
# virsh domblklist <VMNAME>
Target Source
vda /path/to/<VMNAME>.qcow2

Create an external disk snapshot:
# virsh snapshot-create-as --domain <VMNAME> <VMNAME>-snap1 --disk-only --atomic --quiesce

Now that the guest is using the external snapshot disk we can take a backup of the original disk in background using your favorite tool.

When the backup is finished, perform active blockcommit by live merging contents of <VMNAME>-snap1 into base:
# virsh blockcommit <VMNAME> vda --active --verbose --pivot
Block Commit: [100 %]
Successfully pivoted

List the current block device in use, again. It can be noticed, once the blockcommit operation is completed, the live QEMU is pivoted to the base image again:
# virsh domblklist <WMNAME>
Target Source
vda /path/to/<VMNAME>.qcow2

Finaly, if we want, we can remove the external snapshot to not to leave it there:

# virsh snapshot-delete <VMNAME> <VMNAME>-snap1 --metadata
Domain snapshot <VMNAME>-snap1 deleted

Then remove the <VMNAME>-snap1.qcow2 file created above.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.