WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

[Xen-users] Re: Data Backup and Restore Scripts for your Xen Servers

To: xen-users@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-users] Re: Data Backup and Restore Scripts for your Xen Servers
From: "Mr. Teo En Ming (Zhang Enming)" <space.time.universe@xxxxxxxxx>
Date: Sun, 15 Nov 2009 09:02:36 +0800
Cc: space.time.universe@xxxxxxxxx
Delivery-date: Sat, 14 Nov 2009 17:03:50 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=sM0gvp1l5AnJByq+XTFhuHxdUuk7uMFfhThL46DAjfs=; b=wPHfJBrRGrrIDUacKjiKgD4EPJuw6RbgCRUuI1fdMv6H4lm/v5mjdR4cq5TuMXp8P5 kK1thuzjzliLfmc2JGmfLMhICxUnoKXBEHndV69GHeY8d1ufHPXo1ySQsMedmGnWyd0C /c3Wcf/f6EzzzpyQU4/vPy5XEqy0KD8IUPVh0=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=iqgcnNlu5LDqOdD7mX/tPCmJw/4ZLMHnlzime/k5ByiTFH3DYVB++I9ZO+q2y4OoKq vwoD59cWwAM9r7Gtwqtab7kNMWG2nFzbJ2bfMpqke1l6MYacHXlx1DqP60/41JNG11s0 DyOUBeNTGDE4Vjk15XxTk42cIHvlzR40uKPMM=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <f712b9cf0911131134j710abb86oe19392067a41cfc6@xxxxxxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
References: <f712b9cf0911130556u2a3fef71of3f18a4955c8288f@xxxxxxxxxxxxxx> <f712b9cf0911131134j710abb86oe19392067a41cfc6@xxxxxxxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx


On Sat, Nov 14, 2009 at 3:34 AM, Mr. Teo En Ming (Zhang Enming) <space.time.universe@xxxxxxxxx> wrote:
>
>
> On Fri, Nov 13, 2009 at 9:56 PM, Mr. Teo En Ming (Zhang Enming)
> <space.time.universe@xxxxxxxxx> wrote:
>>
>> There are 2 file attachments in this email. One is for harddisk cloning,
>> the other is for data restoration. If there are any bugs with the scripts,
>> please let me know.
>>
>> Thank you.
>>
>> --
>> 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
>
> Attached updates to backup and restore scripts.
>
>
>

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.

--
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

Attachment: xen-dom0-domU-cloning-script.sh.txt
Description: Text document

Attachment: restore.sh.txt
Description: Text document

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users
<Prev in Thread] Current Thread [Next in Thread>