Re: Simple Harddisk Backup/Cloning and Data Restore Scripts for your Fedora Desktops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Fri, Nov 13, 2009 at 10:28 PM, Mr. Teo En Ming (Zhang Enming) <space.time.universe@xxxxxxxxx> wrote:
Restore script:

<CODE>
---snipped---
</CODE>



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>

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
-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux