KVM snapshot backups with qemu-img

November 22, 2010

I noticed that a new feature had been added to qemu-img which allowed for copying a snapshot out of a qcow2 image to become it’s own qcow2 image.  This would allow me to make live snapshots of my running KVM instances and archive them off to another machine.  I got around to testing it this morning and it appears to work fine, streaming back “Big Buck Bunny” whilst archiving off my test machine resulted in only a couple of slight (0.5 sec maybe) pauses.

I’ve produced a small script which allows me to make a backup of the current image, it’s available here, note since I’ve had to compile head of qemu-img I’ve chosen not to overwrite my Lucid version, and have instead called it qemu-img2.

Advertisements

4 Responses to “KVM snapshot backups with qemu-img”

  1. Anonymous said

    One question, does this procedure work for instances that have two image files? like the main .img file and
    another .img that works as a second virtual disk??
    Would i have to create snapshots for both images or by creating one of the principal image would be sufficient??
    thanks!

  2. Andrew Martin said

    Please note that this procedure will introduce corruption into the original qcow2 image file. I contacted the maintainer of qemu-img, and he said that “qemu-img snapshot” should never be used on a running image. The safe alternative he suggested would be to use the external snapshots feature of libvirt, which it looks like will be available in Ubuntu 12.10 Quantal:
    http://www.linux-kvm.com/content/first-look-virtual-machine-online-disk-snapshots-coming-fedora-18

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: