Ubuntu – Backup of KVM guests when using qcow2 disk files

backupkvm-virtualizationqcow2Ubuntuvirtualization

I got a Ubuntu (hardy) system used for virtualization using KVM. Each guest got it's own qcow2 file used as disk. Guests are running Ubuntu (hardy). What would a good backup strategy be for such a setup? I would prefer not to shutdown the guests during backup.

Best Answer

You'll want to coordinate that within the guest .. ideally you:

  1. Cause any RDBMS running in the guest to flush its cache
  2. Tell Linux to sync disks (sysrq S or just type 'sync')

Then just make a qcow2 snapshot of the guest. You then have a read-only immutable copy of the guest FS as it was when you took the snapshot.

This page offers a lot more information than you probably wanted to know on how snapshots (and qcow2 itself) works. See also the accepted answer to this question.