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.
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!
I’d imagine you need to do it for each image disk since the snapshot exists in the img file.
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
thanks that info will be very helpful since this post still gets hits but I no longer use KVM following a job change.