BackupPC-users

Re: [BackupPC-users] pre/post backup script for KVM guests

2009-10-19 12:32:35
Subject: Re: [BackupPC-users] pre/post backup script for KVM guests
From: Daniel Berteaud <daniel AT firewall-services DOT com>
To: "Tyler J. Wagner" <tyler AT tolaris DOT com>
Date: Mon, 19 Oct 2009 18:29:35 +0200
Le lundi 19 octobre 2009 à 14:36 +0100, Tyler J. Wagner a écrit :
> Very handy, Daniel, thank you.
> 
> Why do it this way?  That is, why not back up the VMs like any other server?

I do both. Backup the VM at the file system level, like any other real
server, but I also backup the VM at the block device level, because it
provides a very easy/fast disaster recovery mecanism. If the --state
flag is present, I can restore the guest in the exact state it was when
the backup was made (including running programs, opened files etc...).
Without the --state flag, I can restore it, just as if the guest had
crashed (power failure).

Regards

> 
> Regards,
> Tyler
> 
> On Monday 19 October 2009 14:02:58 Daniel Berteaud wrote:
> > Hi everyone.
> > 
> > I've written a script to backup virtual machines managed by libvirt
> > (only tested with KVM guests, but should works for Xen too, maybe others
> > as well).
> > 
> > It's called virt-backup.pl
> > 
> > I've written it for integration with BackupPC:
> > - take a dump of a VM in using the pre-backup facility
> > - backup the dumps using BackupPC
> > - cleanup the dumps in the post-backup phase
> > 
> > This script can be used outside of BackupPC as it's quite generic.
> > 
> > There are two main mode for this script:
> > --pre: take the backup of the VM. This is called --pre because I use it
> > as a pre-backup script for BackupPC
> > --post: cleanup the dumps
> > 
> > Here're some functionalities:
> > 
> > - no configuration file needed, everything can be passed as command line
> > arg
> > - can take snapshots of virtual disks if they are on LVM Logical volume
> > (the default is to try LVM in any case, if it's not possible, then, just
> > dump the block device/file)
> > - Supports backup of running VM with minimal downtime (if each virtual
> > disks can be snapshoted, just resume the VM immediately resulting in
> > just a few seconds of downtime, then, dump the snapshots. If snapshots
> > are not available, the guest is suspended during the dump)
> > - can save the state of running vm (equivalent of virsh save/virsh
> > restore). This is optional because it's still not very reliable, and
> > sometimes the restoration fails, leaving a crashed qemu process running
> > and eating CPU cycles.
> > - Can compress on-the-fly the virtual disks dumps
> > (gzip,bzip2,pbzip2,lzop,xz)
> > - Support virtual disks exclusions (if you want to backup the system
> > disk of a VM, but not the data one for example)
> > - Can work on installations where virtual disks are stored on one hosts,
> > and guests runs on another on (NFS, iscsi etc... in any case, the script
> > must be run on the host which holds the virtual disks)
> > - Can backup as many guests as you want in one run (they'll be dumped
> > sequentially)
> > - Backups are run with low priority (nice and ionice), so it should'nt
> > slow down too much your system.
> > 
> > Here are the dependencies for this script to work
> > - Sys::Virt perl module
> > - XML::Simple per module
> > - Getopt::Long perl module
> > - lvm2
> > - gzip (optional)
> > - bzip2 (optional)
> > - pbzip2 (optional)
> > - lzop (optional)
> > - xz (optional)
> > 
> > You can run this script without argument to see the help. Edit it if you
> > want more informations (there are some examples on how to use it at the
> > beginning of the script).
> > 
> > 
> > The script can be found here:
> > 
> > http://repo.firewall-services.com/misc/virt-backup.pl
> > 
> > Regards, Daniel
> > 
> 
-- 
Daniel Berteaud
FIREWALL-SERVICES SARL.
Société de Services en Logiciels Libres
Technopôle Montesquieu
33650 MARTILLAC
Tel : 05 56 64 15 32
Fax : 05 56 64 15 32
Mail: daniel AT firewall-services DOT com
Web : http://www.firewall-services.com


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/
<Prev in Thread] Current Thread [Next in Thread>