|
|
|
|
|
|
|
|
|
|
xen-users
[Xen-users] Re: Data Backup and Restore Scripts for your Xen Servers
On Sun, Nov 15, 2009 at 9:02 AM, Mr. Teo En Ming (Zhang Enming) <space.time.universe@xxxxxxxxx> wrote:
Hi All,
I have tested my self-written harddisk backup/cloning script by performing a backup of my Western Digital 500 GB SATA harddisk to my 160 GB Hitachi harddisk.
The backup operation is successful except for 3 virtual machines. The backup of these 3 virtual machines fail because partimage does not support ext4 filesystems. I have performed a backup of these 3 VMs *again* using the following modified script to handle ext4 filesystems by using fsarchiver:
<SCRIPT> #!/bin/sh
############################################################################################################### # Declare Variables ###############################################################################################################
HARDDISK=/dev/sda DEST=/media/hitachi/redo FSA_COMPLEVEL=3 PROCESSOR_CORES=2 GZIP_COMPLEVEL=fast PARTIMAGE_COMPLEVEL=1
###############################################################################################################
# Create Storage Directory for Backup Images ###############################################################################################################
if [ ! -d $DEST ] then mkdir -p $DEST
fi
# VM 19: openSUSE 11.2 x86_64 Linux PV domU ###############################################################################################################
# Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/opensuse
# Backup MBR dd if=/dev/virtualmachines/opensuse of=$DEST/virtualmachines-opensuse.mbr bs=512 count=1
# Backup Partition Geometry sfdisk -d /dev/virtualmachines/opensuse > $DEST/virtualmachines-opensuse.sfdisk
# Backup Filesystems # partimage does not support ext4 filesystems #partimage -d -M -b -z$PARTIMAGE_COMPLEVEL save /dev/mapper/virtualmachines-opensuse2 \ #$DEST/virtualmachines-opensuse2.img
fsarchiver savefs -v -z $FSA_COMPLEVEL -j $PROCESSOR_CORES $DEST/virtualmachines-opensuse2.fsa \
/dev/mapper/virtualmachines-opensuse2
# Delete partition mappings in /dev/mapper kpartx -dv /dev/virtualmachines/opensuse
# VM 16: Slackware64 13.0 amd64 HVM domU ###############################################################################################################
# Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/slackware64
# Backup MBR dd if=/dev/virtualmachines/slackware64 of=$DEST/virtualmachines-slackware64.mbr bs=512 count=1
# Backup Partition Geometry
sfdisk -d /dev/virtualmachines/slackware64 > $DEST/virtualmachines-slackware64.sfdisk
# Backup Filesystems # partimage does not support ext4 filesystems #partimage -d -M -b -z$PARTIMAGE_COMPLEVEL save /dev/mapper/virtualmachines-slackware64p1 \
#$DEST/virtualmachines-slackware64p1.img
#partimage -d -M -b -z$PARTIMAGE_COMPLEVEL save /dev/mapper/virtualmachines-slackware64p2 \ #$DEST/virtualmachines-slackware64p2.img
fsarchiver savefs -v -z $FSA_COMPLEVEL -j $PROCESSOR_CORES $DEST/virtualmachines-slackware64p1.fsa \
/dev/mapper/virtualmachines-slackware64p1
fsarchiver savefs -v -z $FSA_COMPLEVEL -j $PROCESSOR_CORES $DEST/virtualmachines-slackware64p2.fsa \ /dev/mapper/virtualmachines-slackware64p2
# Delete partition mappings in /dev/mapper
kpartx -dv /dev/virtualmachines/slackware64
# VM 17: Ubuntu 9.10 Karmic Koala Linux HVM domU ###############################################################################################################
# Add partition mappings in /dev/mapper kpartx -av /dev/virtualmachines/ubuntu910
# Backup MBR dd if=/dev/virtualmachines/ubuntu910 of=$DEST/virtualmachines-ubuntu910.mbr bs=512 count=1
# Backup Partition Geometry
sfdisk -d /dev/virtualmachines/ubuntu910 > $DEST/virtualmachines-ubuntu910.sfdisk
# Backup Filesystems # partimage does not support ext4 filesystems #partimage -d -M -b -z$PARTIMAGE_COMPLEVEL save /dev/mapper/virtualmachines-ubuntu910p1 \
#$DEST/virtualmachines-ubuntu910p1.img
fsarchiver savefs -v -z $FSA_COMPLEVEL -j $PROCESSOR_CORES $DEST/virtualmachines-ubuntu910p1.fsa \ /dev/mapper/virtualmachines-ubuntu910p1
# Delete partition mappings in /dev/mapper
kpartx -dv /dev/virtualmachines/ubuntu910
# EOF </SCRIPT>
I have attached the latest harddisk backup and restore scripts in this email at the time of this writing. Forgot to mention that the duration of harddisk cloning has been shortened from 7 hours to 4.5 hours. The filesize of the backup image set has been reduced from 300 GB to 126 GB, which is a substantial reduction of more than 50%.
-- Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics) BEng(Hons)(Mechanical Engineering) Alma Maters: (1) Singapore Polytechnic (2) National University of Singapore My Primary Blog: http://teo-en-ming-aka-zhang-enming.blogspot.com
My Secondary Blog: http://enmingteo.wordpress.com My Youtube videos: http://www.youtube.com/user/enmingteo Email: space.time.universe@xxxxxxxxx
Mobile Phone (Starhub Prepaid): +65-8369-2618 Street: Bedok Reservoir Road Country: Singapore
_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users
|
|
|
|
|