PDA

View Full Version : [all variants] Backing up KVM/libvirt virtual machines automatically


stephanhughson
February 9th, 2009, 11:42 AM
Hi,

I was wondering what is the (best) way everyone out there has found to back up their virtual machines? I'm using KVM with the virtual machines controlled through libvirt.

libvirt has a couple of features that might help, but what I'd really like is to avoid suspending or rebooting the virtual machine. The aim is to have a complete snapshot of the drive (memory if possible) that can be used in case of a disaster recovery.

Losing stuff in memory / requiring an fsck on restore isn't the end of the world for me... I would probably back up the personal data / user files separately anyway. In fact, it would be great if the image could *not* include the data!

Mondorescue actually ticks most of the boxes in regards to what I want, but although I have messed about with it quite a bit, I haven't got it working yet.

What does everyone out there do? I'm interested to know, even if it's something basic.

Thanks

Blinkiz
April 4th, 2009, 07:27 AM
Hi there
All my virtual machines disc storage are in separated logical volumes.
So for example, my file server has the path /dev/vg/fileserver and mail server /dev/vg/mail.

You can easily do LVM snapshots. In fact, it's the only way I know it's possible to do a live snapshot of a running machine. When you have done the snapshot, you can mount the new volume in any way you want. I for example, mount this snapshots in my virtual machine responsible for backups. Bacula.

The above solution is not automated in any good way. So you have to create bash scripts and so on to get this automated.

God luck!

stephanhughson
April 23rd, 2009, 07:46 AM
Thanks. I think that's the best way. I spoke to someone who runs a KVM virtual machine hosting service and also someone who has a build/test system running Xen virtual servers. That's how they both recommend doing it as well.

For me just now, I have made a script that suspends each virtual machine, then simply copies the disk image file. It takes about 20 seconds per machine. I have split up my .qcow2 images so that there is a small one (about 4 gigs) for the operating system, then a larger one mounted for the data (e.g. home directories etc). It's basic, but will do for the moment. :P