On Thu, Nov 19, 2009 at 3:54 AM, Mr. Teo En Ming (Zhang Enming) <span dir="ltr">&lt;<a href="mailto:space.time.universe@gmail.com">space.time.universe@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<font size="4"><b>FINAL Restore script as at 19 November 2009 3:52 A.M. SGT</b></font><br><br>&lt;CODE&gt;<br>
&lt;/CODE&gt;<br>
</blockquote></div><br>Hi All,<br><br>I have performed an extensive testing of the restore of the data backup image set using my backup and restore scripts.<br><br>Two virtual machines, namely, openSUSE 11.2 PV domU, and Slackware64 13.0 HVM domU, did not restore properly.<br>

<br>Please refer to my latest updated restore script for the fixes to these problems.<br><br><font size="4"><b>FINAL Restore script as at 21 November 2009 Saturday 12:32 A.M. SGT<br></b></font><br>&lt;CODE&gt;<br><font size="1">#!/bin/sh<br>
<br>set -x<br><br>###############################################################################################################<br>###############################################################################################################<br>
# Script to Restore Xen Host/Dom0 and all DomUs which are using Logical Volumes as Virtual Hard Disks<br>###############################################################################################################<br>###############################################################################################################<br>
<br># Written by:<br> <br># Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics) BEng(Hons)(Mechanical Engineering)<br># Alma Maters:<br># (1) Singapore Polytechnic<br># (2) National University of Singapore<br># Primary Blog: <a href="http://teo-en-ming-aka-zhang-enming.blogspot.com">http://teo-en-ming-aka-zhang-enming.blogspot.com</a><br>
# Secondary Blog: <a href="http://enmingteo.wordpress.com">http://enmingteo.wordpress.com</a><br># Youtube Videos: <a href="http://www.youtube.com/user/enmingteo">http://www.youtube.com/user/enmingteo</a><br># Xen Tutorials and Video Demos: <a href="http://www.xen.org/support/tutorial.html">http://www.xen.org/support/tutorial.html</a><br>
# Email: <a href="mailto:space.time.universe@gmail.com">space.time.universe@gmail.com</a><br># MSN: <a href="mailto:teoenming@hotmail.com">teoenming@hotmail.com</a><br># Mobile Phone (Starhub Prepaid): +65-8369-2618<br># Street: Bedok Reservoir Road<br>
# Country: Singapore<br><br># First written: 13 November 2009 Friday 6:49 P.M. Singapore time<br># Last updated: 13 November 2009 Friday 8:25 P.M. Singapore time<br># Last updated: 13 November 2009 Friday 8:59 P.M. Singapore time<br>
# Last updated: 13 November 2009 Friday 9:40 P.M. Singapore time<br># Last updated: 14 November 2009 Saturday 3:31 A.M. Singapore time<br># Last updated: 15 November 2009 Sunday 1:25 A.M. Singapore time<br># Last updated: 15 November 2009 Sunday 8:38 A.M. Singapore time<br>
# Last updated: 19 November 2009 Thursday 2:35 A.M. Singapore time<br># Last updated: 19 November 2009 Thursday 3:40 A.M. Singapore time<br># Last updated: 20 November 2009 Friday 6:55 P.M. Singapore time<br><br># REFERNCE: &quot;Geek Sheet: Bare-metal backup and recovery&quot;, May 7th, 2008, Jason Perlow<br>
# URL: <a href="http://blogs.zdnet.com/BTL/?p=8759">http://blogs.zdnet.com/BTL/?p=8759</a><br><br># Usage Instructions:<br><br># Boot up your desktop/server with System Rescue CD version 1.3.2 for i386/amd64. <br># Then execute this restore script. You need to adapt this script to work for your environment.<br>
# Download System Rescue CD from <a href="http://www.sysresccd.org/Main_Page">http://www.sysresccd.org/Main_Page</a><br><br># No. of QC Checks Performed on this restore script: 1 <br><br>###############################################################################################################<br>
# Declare Variables<br>###############################################################################################################<br><br>HARDDISK=/dev/sda<br>SOURCE=/mnt/hitachi/Xen-VGA-Passthrough-FINAL-Update-2-2009-11-15-02-img<br>
<br>###############################################################################################################<br>###############################################################################################################<br>
# Restoring Xen Host/Dom0<br>###############################################################################################################<br>###############################################################################################################<br>
<br># Restore the Master Boot Record<br>dd if=$SOURCE/f11-xen-dom0-sda.mbr of=$HARDDISK bs=512 count=1<br><br># Restore the Partition Geometry<br>sfdisk --force --no-reread $HARDDISK &lt; $SOURCE/f11-xen-dom0-partition-geometry-sda.sfdisk<br>
<br># Re-create the LVM2 PV containing the host operating system/dom0<br>#pvcreate --uuid ??? /dev/sda2<br>pvcreate -f /dev/sda2<br><br># Re-create the LVM2 PV containing all the virtual machines<br>#pvcreate --uuid ??? /dev/sda3<br>
pvcreate -f /dev/sda3<br><br># Restore the LVM2 metadata for the volume group containing the host operating system/dom0<br>vgcfgrestore --file $SOURCE/vg_fedora11_host-vgcfg.lvm2.metadata vg_fedora11_host<br><br># Restore the LVM2 metadata for the volume group containing all the virtual machines<br>
vgcfgrestore --file $SOURCE/virtualmachines-vgcfg.lvm2.metadata virtualmachines<br><br># Activate all the volume groups<br>vgchange -ay<br><br># Restore all filesystems for the host operating system/dom0<br>fsarchiver restfs -v $SOURCE/f11-xen-dom0-filesystems.fsa id=0,dest=/dev/sda1 \<br>
id=1,dest=/dev/vg_fedora11_host/lv_home \<br>id=2,dest=/dev/vg_fedora11_host/lv_root \<br>id=3,dest=/dev/vg_fedora11_host/lv_var<br><br># Re-create the swap partition<br>mkswap /dev/vg_fedora11_host/lv_swap<br><br>###############################################################################################################<br>
###############################################################################################################<br># Restoring Xen-based Virtual Machines/DomUs/Guest Operating Systems/VMs<br>###############################################################################################################<br>
###############################################################################################################<br><br>### NOTE: Check for swap partitions in each virtual machine and do a mkswap.<br><br># VM 1: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center)<br>
###############################################################################################################<br><br>zcat $SOURCE/virtualmachines-f11-pv-hpc-node0001.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0001<br>
<br># VM 2: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center)<br>###############################################################################################################<br><br>zcat $SOURCE/virtualmachines-f11-pv-hpc-node0002.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0002<br>
<br># VM 3: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center)<br>###############################################################################################################<br><br>zcat $SOURCE/virtualmachines-f11-pv-hpc-node0003.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0003<br>
<br># VM 4: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center)<br>###############################################################################################################<br><br>zcat $SOURCE/virtualmachines-f11-pv-hpc-node0004.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0004<br>
<br># VM 5: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center)<br>###############################################################################################################<br><br>zcat $SOURCE/virtualmachines-f11-pv-hpc-node0005.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0005<br>
<br># VM 6: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center)<br>###############################################################################################################<br><br>zcat $SOURCE/virtualmachines-f11-pv-hpc-node0006.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0006<br>
<br># VM 7: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center)<br>###############################################################################################################<br><br>zcat $SOURCE/virtualmachines-f11-pv-hpc-node0007.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0007<br>
<br># VM 8: Fedora 11 x86_64 PV domU (MPICH2 Virtual Supercomputer Center)<br>###############################################################################################################<br><br>zcat $SOURCE/virtualmachines-f11-pv-hpc-node0008.img.gz | dd of=/dev/virtualmachines/f11-pv-hpc-node0008<br>
<br># VM 9: FreeBSD 8.0 RC2 UNIX amd64 HVM domU<br>###############################################################################################################<br><br>zcat $SOURCE/virtualmachines-freebsd.img.gz | dd of=/dev/virtualmachines/freebsd<br>
<br># VM 10: OpenSolaris 2009.06 UNIX amd64 PV domU<br>###############################################################################################################<br><br>zcat $SOURCE/virtualmachines-opensolaris.img.gz | dd of=/dev/virtualmachines/opensolaris<br>
<br># VM 11: Rocks 5.1 x86_64 HPC Compute Cluster HVM domU (based on CentOS 5.2)<br>###############################################################################################################<br><br># Add partition mappings in /dev/mapper<br>
kpartx -av /dev/virtualmachines/rocks0001<br><br># Restore MBR<br>dd if=$SOURCE/virtualmachines-rocks0001.mbr of=/dev/virtualmachines/rocks0001 bs=512 count=1<br><br># Restore partition geometry<br>sfdisk --force --no-reread /dev/virtualmachines/rocks0001 &lt; $SOURCE/virtualmachines-rocks0001.sfdisk<br>
<br># Restore all filesystems<br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0001p1 $SOURCE/virtualmachines-rocks0001p1.img.000<br><br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0001p2 $SOURCE/virtualmachines-rocks0001p2.img.000<br>
<br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0001p5 $SOURCE/virtualmachines-rocks0001p5.img.000<br><br># Re-create swap<br>mkswap /dev/mapper/virtualmachines-rocks0001p3<br><br># Delete partition mappings in /dev/mapper<br>
kpartx -dv /dev/virtualmachines/rocks0001<br><br># VM 12: Rocks 5.1 x86_64 HPC Compute Cluster HVM domU (based on CentOS 5.2)<br>###############################################################################################################<br>
<br># Add partition mappings in /dev/mapper<br>kpartx -av /dev/virtualmachines/rocks0002<br><br># Restore MBR<br>dd if=$SOURCE/virtualmachines-rocks0002.mbr of=/dev/virtualmachines/rocks0002 bs=512 count=1<br><br># Restore partition geometry<br>
sfdisk --force --no-reread /dev/virtualmachines/rocks0002 &lt; $SOURCE/virtualmachines-rocks0002.sfdisk<br><br># Restore all filesystems<br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0002p1 $SOURCE/virtualmachines-rocks0002p1.img.000<br>
<br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0002p2 $SOURCE/virtualmachines-rocks0002p2.img.000<br><br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0002p5 $SOURCE/virtualmachines-rocks0002p5.img.000<br>
<br># Re-create swap<br>mkswap /dev/mapper/virtualmachines-rocks0002p3<br><br># Delete partition mappings in /dev/mapper<br>kpartx -dv /dev/virtualmachines/rocks0002<br><br># VM 13: Rocks 5.1 x86_64 HPC Compute Cluster HVM domU (based on CentOS 5.2)<br>
###############################################################################################################<br><br># Add partition mappings in /dev/mapper<br>kpartx -av /dev/virtualmachines/rocks0003<br><br># Restore MBR<br>
dd if=$SOURCE/virtualmachines-rocks0003.mbr of=/dev/virtualmachines/rocks0003 bs=512 count=1<br><br># Restore partition geometry<br>sfdisk --force --no-reread /dev/virtualmachines/rocks0003 &lt; $SOURCE/virtualmachines-rocks0003.sfdisk<br>
<br># Restore all filesystems<br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0003p1 $SOURCE/virtualmachines-rocks0003p1.img.000<br><br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0003p2 $SOURCE/virtualmachines-rocks0003p2.img.000<br>
<br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0003p5 $SOURCE/virtualmachines-rocks0003p5.img.000<br><br># Re-create swap<br>mkswap /dev/mapper/virtualmachines-rocks0003p3<br><br># Delete partition mappings in /dev/mapper<br>
kpartx -dv /dev/virtualmachines/rocks0003<br><br># VM 14: Rocks 5.1 x86_64 HPC Compute Cluster HVM domU (based on CentOS 5.2)<br>###############################################################################################################<br>
<br># Add partition mappings in /dev/mapper<br>kpartx -av /dev/virtualmachines/rocks0004<br><br># Restore MBR<br>dd if=$SOURCE/virtualmachines-rocks0004.mbr of=/dev/virtualmachines/rocks0004 bs=512 count=1<br><br># Restore partition geometry<br>
sfdisk --force --no-reread /dev/virtualmachines/rocks0004 &lt; $SOURCE/virtualmachines-rocks0004.sfdisk<br><br># Restore all filesystems<br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0004p1 $SOURCE/virtualmachines-rocks0004p1.img.000<br>
<br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0004p2 $SOURCE/virtualmachines-rocks0004p2.img.000<br><br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0004p5 $SOURCE/virtualmachines-rocks0004p5.img.000<br>
<br># Re-create swap<br>mkswap /dev/mapper/virtualmachines-rocks0004p3<br><br># Delete partition mappings in /dev/mapper<br>kpartx -dv /dev/virtualmachines/rocks0004<br><br># VM 15: Rocks 5.1 x86_64 HPC Compute Cluster HVM domU (based on CentOS 5.2)<br>
###############################################################################################################<br><br># Add partition mappings in /dev/mapper<br>kpartx -av /dev/virtualmachines/rocks0005<br><br># Restore MBR<br>
dd if=$SOURCE/virtualmachines-rocks0005.mbr of=/dev/virtualmachines/rocks0005 bs=512 count=1<br><br># Restore partition geometry<br>sfdisk --force --no-reread /dev/virtualmachines/rocks0005 &lt; $SOURCE/virtualmachines-rocks0005.sfdisk<br>
<br># Restore all filesystems<br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0005p1 $SOURCE/virtualmachines-rocks0005p1.img.000<br><br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0005p2 $SOURCE/virtualmachines-rocks0005p2.img.000<br>
<br>partimage -e -b restore /dev/mapper/virtualmachines-rocks0005p5 $SOURCE/virtualmachines-rocks0005p5.img.000<br><br># Re-create swap<br>mkswap /dev/mapper/virtualmachines-rocks0005p3<br><br># Delete partition mappings in /dev/mapper<br>
kpartx -dv /dev/virtualmachines/rocks0005<br><br># VM 16: Slackware64 13.0 amd64 HVM domU<br>###############################################################################################################<br><br># Add partition mappings in /dev/mapper<br>
kpartx -av /dev/virtualmachines/slackware64<br><br># Restore MBR<br>dd if=$SOURCE/virtualmachines-slackware64.mbr of=/dev/virtualmachines/slackware64 bs=512 count=1<br><br># Restore partition geometry<br>sfdisk --force --no-reread /dev/virtualmachines/slackware64 &lt; $SOURCE/virtualmachines-slackware64.sfdisk<br>
<br># Restore all filesystems<br># partimage does not support ext4 filesystems<br>#partimage -e -b restore /dev/mapper/virtualmachines-slackware64p1 $SOURCE/virtualmachines-slackware64p1.img.000<br><br>#partimage -e -b restore /dev/mapper/virtualmachines-slackware64p2 $SOURCE/virtualmachines-slackware64p2.img.000<br>
<br>fsarchiver restfs -v $SOURCE/virtualmachines-slackware64p1.fsa \<br>id=0,dest=/dev/mapper/virtualmachines-slackware64p1<br><br>fsarchiver restfs -v $SOURCE/virtualmachines-slackware64p2.fsa \<br>id=0,dest=/dev/mapper/virtualmachines-slackware64p2<br>
<br># Re-create swap<br>mkswap /dev/mapper/virtualmachines-slackware64p3<br><br># Delete partition mappings in /dev/mapper<br>kpartx -dv /dev/virtualmachines/slackware64<br><br># After data restoration for Slackware64 domU is completed, it is necessary to reinstall the LILO Linux Loader <br>
# boot loader. Otherwise, you will get the &quot;L 99 99 99&quot; error during bootup of the Slackware64 virtual machine.<br># Amend the Slackware64 domU configuration so that it boots up with the Slackware64 13.0 DVD ISO image file.<br>
# Simply press enter at the boot prompt and login using the root account.<br># ls /dev/hd*<br># mkdir -p /mnt/slack/boot<br># mount /dev/hda2 /mnt/slack<br># mount /dev/hda1 /mnt/slack/boot<br># chroot /mnt/slack /sbin/lilo<br>
# umount /mnt/slack<br># umount /mnt/slack/boot<br># Shutdown the virtual machine. Change the boot order of the domU to harddisk, and start Slackware64 HVM<br># domU again.<br><br># VM 17: Ubuntu 9.10 Karmic Koala Linux HVM domU<br>
###############################################################################################################<br><br># Add partition mappings in /dev/mapper<br>kpartx -av /dev/virtualmachines/ubuntu910<br><br># Restore MBR<br>
dd if=$SOURCE/virtualmachines-ubuntu910.mbr of=/dev/virtualmachines/ubuntu910 bs=512 count=1<br><br># Restore partition geometry<br>sfdisk --force --no-reread /dev/virtualmachines/ubuntu910 &lt; $SOURCE/virtualmachines-ubuntu910.sfdisk<br>
<br># Restore all filesystems<br># partimage does not support ext4 filesystems<br>#partimage -e -b restore /dev/mapper/virtualmachines-ubuntu910p1 $SOURCE/virtualmachines-ubuntu910p1.img.000<br><br>fsarchiver restfs -v $SOURCE/virtualmachines-ubuntu910p1.fsa \<br>
id=0,dest=/dev/mapper/virtualmachines-ubuntu910p1<br><br># Re-create swap<br>mkswap /dev/mapper/virtualmachines-ubuntu910p5<br><br># Delete partition mappings in /dev/mapper<br>kpartx -dv /dev/virtualmachines/ubuntu910<br>
<br># VM 18: Windows XP Home Edition SP3 32-bit HVM domU with VGA passthrough (requires Intel VT-d)<br>###############################################################################################################<br><br>
# Add partition mappings in /dev/mapper<br>kpartx -av /dev/virtualmachines/winxphome32<br><br># Restore MBR<br>dd if=$SOURCE/virtualmachines-winxphome32.mbr of=/dev/virtualmachines/winxphome32 bs=512 count=1<br><br># Restore partition geometry<br>
sfdisk --force --no-reread /dev/virtualmachines/winxphome32 &lt; $SOURCE/virtualmachines-winxphome32.sfdisk<br><br># Restore all filesystems<br>partimage -e -b restore /dev/mapper/virtualmachines-winxphome32p1 $SOURCE/virtualmachines-winxphome32p1.img.000<br>
<br># Delete partition mappings in /dev/mapper<br>kpartx -dv /dev/virtualmachines/winxphome32<br><br># VM 19: openSUSE 11.2 x86_64 Linux PV domU<br>###############################################################################################################<br>
<br># Add partition mappings in /dev/mapper<br>kpartx -av /dev/virtualmachines/opensuse<br><br># Restore MBR<br>dd if=$SOURCE/virtualmachines-opensuse.mbr of=/dev/virtualmachines/opensuse bs=512 count=1<br><br># Restore partition geometry<br>
sfdisk --force --no-reread /dev/virtualmachines/opensuse &lt; $SOURCE/virtualmachines-opensuse.sfdisk<br><br># Restore all filesystems<br># partimage does not support ext4 filesystems<br>#partimage -e -b restore /dev/mapper/virtualmachines-opensuse2 $SOURCE/virtualmachines-opensuse2.img.000<br>
<br>fsarchiver restfs -v $SOURCE/virtualmachines-opensuse2.fsa id=0,dest=/dev/mapper/virtualmachines-opensuse2<br><br># Re-create swap<br>mkswap /dev/mapper/virtualmachines-opensuse1<br><br># Delete partition mappings in /dev/mapper<br>
kpartx -dv /dev/virtualmachines/opensuse<br><br># During a full data restore operation, kpartx did not successfully add device mappings in /dev/mapper.<br># Hence no device nodes for partitions in the openSUSE domU were created. As a result, filesystem restore<br>
# for partition 2 did not succeed. Re-creation of swap filesystem also failed because device node did not<br># exist. The solution to this problem is to simply re-run the above steps again.<br><br>###############################################################################################################<br>
###############################################################################################################<br><br># Deactivate Logical Volume Manager<br>vgchange -an<br><br># Sync filesystems<br>sync<br><br># Reinstall GRUB on the restore harddisk before rebooting<br>
# grub<br># grub&gt; root (hd0,0)<br># grub&gt; setup (hd0)<br># grub&gt; quit<br><br># Reboot the machine<br>reboot<br><br>###############################################################################################################<br>
# EOF<br>###############################################################################################################</font><br>&lt;/CODE&gt;<br>