Agent Rooker
2008-Oct-17 21:30 UTC
[Xen-users] Using dd and gzip to backup LVM backed domUs
I''m trying to come up with the best way to backup my xen domUs. I have a logical volume containing an ext3 root filesystem for each domU. Basically, I want to back up the whole filesystem in such a way that I could restore the image on another xen server in the case of hardware failure. My idea so far is to back up the logical volume with a command of this form (from the dom0): # dd if=/dev/VolGroup00/XenImage bs=64k | gzip > /mnt/archive/XenImage_20081017.gz And to restore using a command of this form: # zcat /mnt/archive/XenImage_20081017.gz | dd of=/dev/VolGroup00/XenImage bs=64k I think this should work in a pinch but there are at least two issues that I''d like to sort out. First, one of the reasons I''m using gzip is because I have a lot of free space on my domU logical volume, and I want to compress all that unused space down to (almost) nothing when I make my backup image. At first, this unused space would be all zeros and would therefore compress very nicely. But as I understand it, if a file is deleted, the data remains on the block device. The blocks are no longer allocated by the filesystem, but when I try to compress them, they won''t compress as well as the unused blocks that are all zeros. What I foresee is the compressed image growing in size even though the space used by the domU''s filesystem remains relatively steady. One idea would be to periodically zero out the unused blocks by filling up the volume with a file of all zeros with something like this: # dd if=/dev/zero of=foo ; rm foo But I think it would be a bad idea to do this on a mounted root filesystem. So am I right to worry about this, and if so, what should I do about it? The other problem with my backup method is that it only works if the domU is shut down. If the domU is running, the filesystem is backed up in an inconsistent state. I''ve thought about using LVM snapshots for hot backups, but if I take a backup from a snapshot of a running system, would I be able to start up my domU from that volume without losing data? Or would I have to do something like save a checkpoint (using ''xm save''), make a snapshot of the logical volume, restore the DomU, dd the snapshot, and then remove the snapshot? Also, any other ideas for doing what I''m trying to do would also be appreciated. Thanks, -- Agent Rooker _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Javier Guerra
2008-Oct-17 21:40 UTC
Re: [Xen-users] Using dd and gzip to backup LVM backed domUs
On Fri, Oct 17, 2008 at 4:30 PM, Agent Rooker <agentrooker@gmail.com> wrote:> I''m trying to come up with the best way to backup my xen domUs. I > have a logical volume containing an ext3 root filesystem for each > domU. Basically, I want to back up the whole filesystem in such a way > that I could restore the image on another xen server in the case of > hardware failure. My idea so far is to back up the logical volume > with a command of this form (from the dom0):as always, it''s much better to do a backup from the DomU itself. -- Javier _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Agent Rooker
2008-Oct-17 21:59 UTC
Re: [Xen-users] Using dd and gzip to backup LVM backed domUs
I''ve read that there can be problems with MySQL databases (for instance) unless you do FLUSH TABLES WITH READ LOCK; before creating the snapshot, but this would not be a problem if you used this method to do a cold backup (i.e., creating an LVM snapshot while the domU is shut down). Now I''m wondering if it would be best possible to take an LVM snapshot and a xen checkpoint at the same time so that if the domU does need to be restored, the data not committed to disk would still be in RAM (loaded from the checkpoint file), so there would not be any loss of data upon restore. Also, if someone could explain to me the dangers of hot backups with LVM snapshots, or point me to a website explaining it, that would be very helpful. Thanks again. On Fri, Oct 17, 2008 at 4:40 PM, Javier Guerra <javier@guerrag.com> wrote:> On Fri, Oct 17, 2008 at 4:30 PM, Agent Rooker <agentrooker@gmail.com> wrote: >> I''m trying to come up with the best way to backup my xen domUs. I >> have a logical volume containing an ext3 root filesystem for each >> domU. Basically, I want to back up the whole filesystem in such a way >> that I could restore the image on another xen server in the case of >> hardware failure. My idea so far is to back up the logical volume >> with a command of this form (from the dom0): > > as always, it''s much better to do a backup from the DomU itself. > > -- > Javier >-- Agent Rooker _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users
Tomasz Chmielewski
2008-Oct-17 22:19 UTC
Re: [Xen-users] Using dd and gzip to backup LVM backed domUs
Agent Rooker schrieb:> I''m trying to come up with the best way to backup my xen domUs. I > have a logical volume containing an ext3 root filesystem for each > domU. Basically, I want to back up the whole filesystem in such a way > that I could restore the image on another xen server in the case of > hardware failure. My idea so far is to back up the logical volume > with a command of this form (from the dom0):Unless you have Windows domains, the easiest approach would be to simply copy the files. cp, tar, rsync - pick the one you like. If you want a good backup system, try BackupPC - http://backuppc.sf.net -- Tomasz Chmielewski http://wpkg.org _______________________________________________ Xen-users mailing list Xen-users@lists.xensource.com http://lists.xensource.com/xen-users