Hello
This new HowTo explains how to backup a VM without powering it down. It's specifically aimed at KVM although it may work with any virtualization software that uses Linux as the host.
Please review it and let me know what you think, particularly if you are already doing something similar yourself, or would like to. Do you have answers to any of the questions in the 'Questions' section?
It has not been released yet and it's a first draft, so break it to me gently... http://wiki.centos.org/HowTos/BackupKVMGuest
(The article's internal Wiki links are broken - not sure what's going on there, but ignore that)
A taster...
1. Introduction
This article explains how to backup a virtual hard disk to a remote location, even while it is use.
One advantage of running software in a virtual machine is that the entire disk can be backed up in one go, including Operating System, software, configuration files, registry, permissions, data and all. Re-establishing a system after a failure is therefore quicker and more reliable than re-installing software and restoring data.
The method employs LVM to take a snapshot of the guest disk and then uses rsync to update changes to a previous backup on a remote server. If there is a database server on the guest then it is flushed & locked at the point the snapshot is taken. This method came into use around 2008 following wider availability and awareness of virtualization software, cheaper faster network bandwidth, and cheaper bigger disks. ...
Thanks, Julian
On Wed, Mar 25, 2009 at 01:22:43PM +0000, Julian Price wrote:
It has not been released yet and it's a first draft, so break it to me gently... http://wiki.centos.org/HowTos/BackupKVMGuest
Interesting read. One other alternative, with drbd: 1) break sync on other node 2) backup on other node 3) resync other node
Of course, drbd may not be best suited for disk intensive uses but your milleage may vary...
Rui
Rui Miguel Silva Seabra wrote:
On Wed, Mar 25, 2009 at 01:22:43PM +0000, Julian Price wrote:
It has not been released yet and it's a first draft, so break it to me gently... http://wiki.centos.org/HowTos/BackupKVMGuest
Interesting read. One other alternative, with drbd:
- break sync on other node
- backup on other node
- resync other node
Of course, drbd may not be best suited for disk intensive uses but your milleage may vary...
Rui
drdb - If I understand right, this is another way to take a snapshot - similar to taking one disk out of a RAID1, backing it up then rebuilding the RAID. The LVM snapshot requires space and degrades performance during the backup and your method suffers neither of those disadvantages.
Thanks for the suggestion.
Julian Price wrote on Wed, 25 Mar 2009 18:59:04 +0000:
Thanks for the suggestion.
Another one, although I'm sure that some will loudly protest about it :-) I've had excellent results with rsyncing the complete content of Xen VMs to other Xen VMs. It works flawlessly even for MySQL database in full swing. Maybe it makes a difference if you use InnoDB, I'm using MyISAM whereever I can for reasons of speed and robustness. I've rsynced even heavy use servers with no problems (did a lot of tests to make sure the results worked). Before doing it this way I checked out the LVM snapshot options (e.g. mount a snapshot and rsync that snapshot) as this is usually recommended but found them not really fitting me.
Kai
Kai Schaetzl wrote:
Another one, although I'm sure that some will loudly protest about it :-) I've had excellent results with rsyncing the complete content of Xen VMs to other Xen VMs. It works flawlessly even for MySQL database in full swing. Maybe it makes a difference if you use InnoDB, I'm using MyISAM whereever I can for reasons of speed and robustness. I've rsynced even heavy use servers with no problems (did a lot of tests to make sure the results worked). Before doing it this way I checked out the LVM snapshot options (e.g. mount a snapshot and rsync that snapshot) as this is usually recommended but found them not really fitting me.
Kai
Are you syncing the disk image as one file via the host, or all the files within via the guest?
If you're syncing the image then I'd be interested to know how you do that if Xen is the host. Can you run rsync on Xen? I thought it was just a hypervisor. Or can Dom0 access the images of other guests to rsync them?
If you are just syncing files in the guest (which I wouldn't protest about) then the methods are not really comparable because the essential point of my approach is that the whole bootable image is backed up, which is desirable to some people for lots of reasons.
Thanks, Julian
Julian Price wrote on Thu, 26 Mar 2009 16:48:36 +0000:
Are you syncing the disk image as one file via the host, or all the files within via the guest?
The sync happens as if I had two physical machines. Phys <backup> logs in to Virt <tobebackupped> on Phys <wherever> and syncs Virt <tobebackupped> to the local storage (be that image, LVM partition or what). I use it to backup to a backup mirror that can take over if the original fails. The complete sync usually takes only a few minutes per VM. (I *could* add a sql flush and lock on the remote side in the custom script that is triggered by the ssh rsync login, but I would need to hold it for longer (during the complete database file sync) as creating a snapshot, of course.)
If you are just syncing files in the guest (which I wouldn't protest about) then the methods are not really comparable because the essential point of my approach is that the whole bootable image is backed up, which is desirable to some people for lots of reasons.
I'm not sure what you mean. I have two identical and working "images" after the sync (actually it's two LVM partitions). If I were using images I had two images after that. It's independant of the storage method for your LVM and you can use different storage on both sides. But is has to be created and formatted before you can use it for backup. For your method I think you just need to create the LVM partition (as large or larger than the source), no formatting. It's also possible that my method doesn't work for HVM guests where you may need a bootloader, I'm using only PV CentOS 5 and 4 guests.
Kai
Kai Schaetzl wrote:
I'm not sure what you mean....
I mean that I am backing up one 32GB virtual disk in one file called vm.img or vm.qcow or vm.vhd depending on the virtual disk format.
The advantage is that - we don't care which operating system is inside the virtual disk file - We can use the LVM snapshot to ensure that the virtual disk file represents a moment in time, and doesn't change during the backup, so it is consistent. - There is no need to hold the database lock during the backup - only at the moment the snapshot is started.
The answer to whether this technique works with Xen is answered 'Yes' on this page: http://wiki.sepsoftware.com/wiki/index.php/Online_backup_of_virtual_XEN_mach... They are using their proprietary backup software instead of rsync but the technique is essentially the same.
Thanks, Julian