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:07:26 +0800
Cc: space.time.universe@xxxxxxxxx
Delivery-date: Sat, 14 Nov 2009 17:08:19 -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=Y8K+6k44RHY0WVCRQP7E+5RIOhbYr4m2LQWGANiHbiA=; b=Q9m56tYwfh3+A7p9nXmES3Kllw2lAv4Q1pBY19y0sZfCSfDH4qF7SkMIYQnL5UWz73 +ABvn2t8F6C/dMeuB6ZDPt0BN+V9CRgpmVvl7WITRMD7ydEFdiUpe+EIqT206M7zkw7W Z5/MWc4vrRbdpKAWuSrV5FGnxsvblSMaz/lh8=
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=paw98IclolrpHFJKlhN0O9hfyB6H4Vzx1NxJYyGZP/Voy7iPh1wmWjATFdkF5FVo8R MR2MfYMYlSR6BjL8JKdRdSk0Xbi8dZlvumKyTRaBD2hpRzKTDR8MCaewTEIiMNvkHbly isAOTJWd2rENDmV6PwMihq9SJ1NUGfbKUCmu0=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <f712b9cf0911141702j53ed314aw88e735bc35e5f7c6@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> <f712b9cf0911141702j53ed314aw88e735bc35e5f7c6@xxxxxxxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx


On Sun, Nov 15, 2009 at 9:02 AM, Mr. Teo En Ming (Zhang Enming) <space.time.universe@xxxxxxxxx> wrote:


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


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
<Prev in Thread] Current Thread [Next in Thread>