Store the cooked outputs of Charles Curley's scripts

In his document build system, each script is cooked (wrapped in <![ CDATA []]>
during build process--this is elegant, but we are not calling his build
Makefile, so we need to store the cooked scripts in the source tree.
This commit is contained in:
Martin A. Brown 2016-01-24 09:16:45 -08:00
parent 270d39e7de
commit d51e1970c4
21 changed files with 2282 additions and 25 deletions

View File

@ -1,24 +1,24 @@
<!doctype article public "-//OASIS//DTD DocBook V4.1//EN"
[ <!entity header system "header.sgml">
<!-- These allow the equivalent of #includes below. C^2 -->
<!ENTITY make.fdisk SYSTEM "cooked/make.fdisk">
<!ENTITY install SYSTEM "cooked/install">
<!ENTITY make.dev.hda SYSTEM "cooked/make.dev.hda">
<!ENTITY make.lvs SYSTEM "cooked/make.lvs">
<!ENTITY mount.dev.hda SYSTEM "cooked/mount.dev.hda">
<!ENTITY mount.lvs SYSTEM "cooked/mount.lvs">
<!ENTITY dev.hda SYSTEM "cooked/dev.hda">
<!ENTITY dev.hda.sfd SYSTEM "cooked/dev.hda.sfd">
<!ENTITY save.metadata SYSTEM "cooked/save.metadata">
<!ENTITY restore.metadata SYSTEM "cooked/restore.metadata">
<!ENTITY back.up.all SYSTEM "cooked/back.up.all">
<!ENTITY back.up.all.ssh SYSTEM "cooked/back.up.all.ssh">
<!ENTITY restore.all SYSTEM "cooked/restore.all">
<!ENTITY restore.all.ssh SYSTEM "cooked/restore.all.ssh">
<!ENTITY get.tester SYSTEM "cooked/get.tester">
<!ENTITY get.target SYSTEM "cooked/get.target">
<!ENTITY restore.tester SYSTEM "cooked/restore.tester">
<!ENTITY first.stage SYSTEM "cooked/first.stage">
<!ENTITY make.fdisk SYSTEM "scripts/cooked/make.fdisk">
<!ENTITY install SYSTEM "scripts/cooked/install">
<!ENTITY make.dev.hda SYSTEM "scripts/cooked/make.dev.hda">
<!ENTITY make.lvs SYSTEM "scripts/cooked/make.lvs">
<!ENTITY mount.dev.hda SYSTEM "scripts/cooked/mount.dev.hda">
<!ENTITY mount.lvs SYSTEM "scripts/cooked/mount.lvs">
<!ENTITY dev.hda SYSTEM "scripts/cooked/dev.hda">
<!ENTITY dev.hda.sfd SYSTEM "scripts/cooked/dev.hda.sfd">
<!ENTITY save.metadata SYSTEM "scripts/cooked/save.metadata">
<!ENTITY restore.metadata SYSTEM "scripts/cooked/restore.metadata">
<!ENTITY back.up.all SYSTEM "scripts/cooked/back.up.all">
<!ENTITY back.up.all.ssh SYSTEM "scripts/cooked/back.up.all.ssh">
<!ENTITY restore.all SYSTEM "scripts/cooked/restore.all">
<!ENTITY restore.all.ssh SYSTEM "scripts/cooked/restore.all.ssh">
<!ENTITY get.tester SYSTEM "scripts/cooked/get.tester">
<!ENTITY get.target SYSTEM "scripts/cooked/get.target">
<!ENTITY restore.tester SYSTEM "scripts/cooked/restore.tester">
<!ENTITY first.stage SYSTEM "scripts/cooked/first.stage">
<!ENTITY longversion "$Header$">

View File

@ -25,16 +25,16 @@ dslprint = -d /usr/share/sgml/docbook/dsssl-stylesheets/ldp.dsl\\\#print
cooked:
-mkdir cooked $(DOCUMENT) $(DOCUMENT).junk
-mkdir scripts/cooked $(DOCUMENT) $(DOCUMENT).junk
clean:
-rm -r $(DOCUMENT) $(DOCUMENT).[a-b]* $(DOCUMENT).[d-r]* $(DOCUMENT).[t-z]* $(DOCUMENT).smooth.html cooked ../images
-rm -r $(DOCUMENT) $(DOCUMENT).[a-b]* $(DOCUMENT).[d-r]* $(DOCUMENT).[t-z]* $(DOCUMENT).smooth.html scripts/cooked ../images
mkdir $(DOCUMENT) $(DOCUMENT).junk
# scripts: $(SCRIPTS)
scripts: cooked
for S in $(SCRIPTS) ; do \
./buildscript $$S ; \
test ! -d scripts/$$S && ./buildscript $$S ; \
done
$(DOCUMENT)/index.html: $(DOCUMENT).sgml scripts

View File

@ -12,12 +12,12 @@ if [ -e scripts/$script ]; then
# does not exist, we add in the SGML source, producing the cooked
# version.
if [ scripts/$script -nt cooked/$script ] || [ ! -e cooked/$script ] ; then
if [ scripts/$script -nt scripts/cooked/$script ] || [ ! -e scripts/cooked/$script ] ; then
echo "rebuilding $script"
echo -n '<![ CDATA [' > cooked/$script
cat scripts/$script >> cooked/$script
echo ']]>' >> cooked/$script
echo -n '<![ CDATA [' > scripts/cooked/$script
cat scripts/$script >> scripts/cooked/$script
echo ']]>' >> scripts/cooked/$script
fi
fi

View File

@ -0,0 +1,47 @@
<![ CDATA [#! /bin/sh
# Back up the entire system to another computer's drive. To make this
# work, we need a convenient chunk of disk space on the remote computer we
# can nfs mount as /mnt/save.
# Time-stamp: <2007-07-06 13:30:43 ccurley back.up.all>
# Copyright 2000 through the last date of modification Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
save="/mnt/save"
# Make sure it's there
umount $save
mount $save
cd /
rm $save/tester.tar.old.gz
mv $save/tester.tar.gz $save/tester.tar.old.gz
# save everything except /mnt, /proc, and nfs mounted directories.
time tar cf - / --exclude /mnt --exclude /proc --exclude $save\
| gzip -c > $save/tester.tar.gz
]]>

View File

@ -0,0 +1,44 @@
<![ CDATA [#! /bin/sh
# Back up the entire system to another computer's drive. To make this
# work, we need a convenient chunk of disk space on the remote
# computer. This version uses ssh to do its transfer, and compresses
# using bz2. This means this script has to know more about the other
# computer, which does not make for good modularization.
# Time-stamp: <2007-07-06 13:30:54 ccurley back.up.all.ssh>
# Copyright 2000 through the last date of modification Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
save="/backs/tester"
backup_server="charlesc"
# rotate the old backups. Do it all in one line to minimze authentication overhead.
ssh $backup_server "rm $save/tester.tar.old.bz2; mv $save/tester.tar.bz2 \
$save/tester.tar.old.bz2"
# save everything except /mnt, /proc, and squid directories.
time tar cf - / --exclude /mnt --exclude /proc --exclude /var/spool/squid\
| ssh $backup_server "bzip2 -9 > $save/tester.tar.bz2"
]]>

View File

@ -0,0 +1,34 @@
<![ CDATA [n
p
1
1
29
a
1
n
p
2
30
44
n
e
3
45
1023
n
l
45
944
n
l
945
1023
t
1
6
t
6
82
v
w
]]>

View File

@ -0,0 +1,9 @@
<![ CDATA [# partition table of /dev/hda
unit: sectors
/dev/hda1 : start= 63, size= 116865, Id= 6, bootable
/dev/hda2 : start= 116928, size= 153216, Id=83
/dev/hda3 : start= 270144, size= 286272, Id=82
/dev/hda4 : start= 556416, size= 3568320, Id= 5
/dev/hda5 : start= 556479, size= 3568257, Id=83
]]>

View File

@ -0,0 +1,86 @@
<![ CDATA [#! /bin/sh
# A master script to run the other, detailed scripts. Use this script
# only if you want no human intervention in the restore process. The
# only option is -c, which forces bad block checking during formatting
# of the partitions.
# Time-stamp: <2007-07-06 13:31:08 ccurley first.stage>
# Copyright 2002 through the last date of modification Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
# 2005-08-07 We no longer assume the working directory. This is
# because the working directory will vary greatly according to which
# Linux disty you use and how you are doing your restoration.
export blockcheck=$1;
if [ "$blockcheck" != "-c" ] && [ -n "$blockcheck" ]
then
echo "${0}: automated restore with no human interaction."
echo "${0}: -c: block check during file system making."
exit 1;
fi
for drive in $( ls make.dev.* ); do
echo $drive$'\a'
sleep 2
./$drive $blockcheck;
done
# If there are any LVM volumes, now is the time to restore them.
if [ -e make.lvs ] && [ -e mount.lvs ]
then
echo make.lvs$'\a'
sleep 2
./make.lvs
echo mount.lvs$'\a'
./mount.lvs
fi
# WARNING: If your Linux system mount partitions across hard drive
# boundaries, you will have multiple "mount.dev.* scripts. You must
# ensure that they run in the proper order, which the loop below may
# not do. The root partition should be mounted first, then the rest in
# the order they cascade. If they cross mount, you'll have to handle
# that manually. If you have LVMs to deal with, that's a whole 'nother
# kettle of fish.
# The "ls -tr" will list the scripts in the order they are created, so
# it might be a good idea to create them (in the script save.metadata)
# in the order in which you should run them.
for drive in $( ls -tr mount.dev.* ); do
echo $drive$'\a'
sleep 2
./$drive;
done
./restore.metadata
# People who are really confident may comment this line in.
# reboot
]]>

View File

@ -0,0 +1,104 @@
<![ CDATA [# -*- shell-script -*-
# Time-stamp: <2007-07-06 13:31:22 ccurley get.target>
# Copyright 2000 through the last date of modification, Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at
# http://www.fsf.org/
# How to determine the target: the directory structure is
# /..../back/hostname.OS.etc So we have to get the name of the
# directory. That gives us host name and OS.etc. From that we extract
# the host name.
path=`pwd`
target=${path##/*/}
host=${target%%.*}
# Run "info date" for more information.
DATE=`date +%Y%m%d`
# echo "Today's date is $DATE."
echo "\$target is $target. \$host is $host. Today's date is $DATE."
name=$0
echo "This is script $name"
if [ $(echo $name | grep -i get > /dev/null) ] ; then
# Do functions common to all restores.
# Which archive do we restore and is this a valid target name?
TARGET=$1
if [ -z $TARGET ] ; then
echo Please specify a target from one of:
for dir in $(ls -d $host.*) ; do
if [ -d $dir ] ; then
echo -n "$dir "
fi
done
exit 2;
fi
if [ -z $TARGET ] || [ ! -d $TARGET ] ; then
echo $TARGET does not exist!
exit 2;
fi
ssh $host rm -r /var/lib/rpm
else
# Do functions common to all gets.
# Where we will get the archives on the target.
#zip=/mnt/zip
export zip="/var/lib/bare.metal.recovery";
# If it does not already exist, build the archive.
ssh $host "if [ ! -d ${zip}/$DATE ] ; then echo Saving metadata... ; save.metadata ; fi"
echo Backing up $host
if [ -e $host.$DATE ] ; then
rm -r $host.$DATE
fi
echo Copying the bare metal recovery archive.
# -r for recursive copy, -p to preserve times and permissions, -q
# for quiet: no progress meter.
scp -qpr $host:$zip/$DATE $host.$DATE
du -hs $host.*
echo Cleaning out old yum packages
ssh $host "yum clean packages"
echo Backing up $host to the backup server.
if [ -e $host.$DATE.tar.bz2 ] ; then
rm $host.$DATE.tar.bz2
fi
fi
]]>

View File

@ -0,0 +1,76 @@
<![ CDATA [#! /bin/sh
# Back up another computer's drive to this system. To make this work,
# we need a convenient chunk of disk space on this computer. This
# version uses ssh to do its transfer, and compresses using bz2. This
# version was developed so that the system to be backed up won't be
# authenticated to log onto the backup computer. This script is
# intended to be used on a firewall. You don't want the firewall to be
# authenticated to the backup system in case the firewall is cracked.
# Time-stamp: <2007-07-06 13:31:40 ccurley get.tester>
# Copyright 2000 through the last date of modification Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
# 2007-05-22: Changes for FHS compliance. Removed commented out
# references to ZIP drives. Now, if the archive does not exist on the
# client, we run save.metadata there.
# 2006-04-14: Use the script ../scripts/get.target to determine the
# host name. This makes the script more general, and maybe we can run
# it from one place & determine the host name from the directory
# name. Also, we now test to see if old backups exist before deleting
# them.
# 2004 04 03: added /sys to the list of excludes. It is a read-only
# pseudo-file system like /proc.
# 2002 07 01: We now set the path on the target to the zip drive with
# a variable. This fixes a bug in the command to eject the zip disk.
# 2002 07 01: The zip disk archives are now in bzip2 format, so this
# script has been changed to reflect that.
# Get the host name of the computer to be backed up and other info.
. ../scripts/get.target
# The "--anchored" option is there to prevent --exclude from excluding
# all files with that name. E.g. we only want to exclude /sys, not
# some other sys elsewhere in the file system.
ssh $host "cd / ; tar -cf - --anchored --exclude media --exclude mnt\
--exclude selinux --exclude sys --exclude proc --exclude var/spool/squid\
--exclude var/cache/yum --exclude var/named/chroot/proc\
--exclude var/lib/bare.metal.recovery * " | bzip2 -9 | cat > $host.$DATE.tar.bz2
# if [ -e $host.dos.$DATE.old.tar.bz2 ] ; then
# rm $host.dos.$DATE.old.tar.bz2
# fi
# echo Backing up $host dos to the backup server.
# ssh $host "cd / ; mount mnt/dosc ; tar -cf - mnt/dosc "\
# | bzip2 -9 | cat > $host.dos.$DATE.tar.bz2
echo Testing the results.
find $host.$DATE* -iname "*.bz2" | xargs bunzip2 -t
]]>

View File

@ -0,0 +1,44 @@
<![ CDATA [#! /bin/sh
# A script to install the bare metal recovery scripts. With any luck,
# this will comply with the "Filesystem Hierarchy Standard",
# http://www.pathname.com/fhs/, version 2.3, announced on January 29,
# 2004.
# Time-stamp: <2007-07-06 13:33:29 ccurley install>
# Copyright 2007 through the last date of modification, Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at
# http://www.fsf.org/
# Where we put the archives ready for making CDs, etc.
mkdir -p /var/lib/bare.metal.recovery
# Keep them secure from pesky snooping users who don't need to be able
# to hack a copy of, say, /etc/shadow.
chmod 700 /var/lib/bare.metal.recovery
# Backup time executables.
cp -rp save.metadata make.fdisk /usr/sbin
# Save the recovery time executables we provide. The archiving
# programs look for them here and save them into the archives.
mkdir -p /etc/bare.metal.recovery
cp -rp first.stage restore.metadata /etc/bare.metal.recovery
]]>

View File

@ -0,0 +1,73 @@
<![ CDATA [#! /bin/sh
# A script to restore the partition data of a hard drive and format
# the partitions. Created at bare metal backup time by the Perl script
# make.fdisk.
# Copyright 2001 through the last date of modification Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
export blockcheck=$1;
if [ "$blockcheck" != "-c" ] && [ -n "$blockcheck" ]
then
echo "${0}: automated restore with no human interaction."
echo "${0}: -c: block check during file system making."
exit 1;
fi
dd if=/dev/zero of=/dev/hda bs=512 count=2
swapoff -a
sync
# see if we have sfdisk & if so use it.
if which sfdisk ; then
echo "Using sfdisk."
sfdisk -H 128 -S 63 -C 523 /dev/hda < dev.hda.sfd
else
echo "using fdisk."
fdisk -H 128 -S 63 -C 523 /dev/hda < dev.hda
fi
sync
echo
echo formatting /dev/hda1
mkdosfs $blockcheck /dev/hda1
# restore FAT boot sector.
dd if=dev.hda1 of=/dev/hda1 bs=512 count=1
echo
echo formatting /dev/hda2
mke2fs -j $blockcheck -L /boot /dev/hda2
echo
echo formatting /dev/hda3
mke2fs -j $blockcheck -L / /dev/hda3
echo Making /dev/hda5 a swap partition.
mkswap $blockcheck /dev/hda5
fdisk -l "/dev/hda"
]]>

View File

@ -0,0 +1,61 @@
<![ CDATA [#! /bin/sh
# A script to create file systems on logical volumes. Created at bare
# metal backup time by the Perl script make.fdisk.
# Copyright 2006 through the last date of modification Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
export blockcheck=$1;
if [ "$blockcheck" != "-c" ] && [ -n "$blockcheck" ]
then
echo "${0}: Build file systems on logical volumes."
echo "${0}: -c: block check during file system making."
exit 1;
fi
export LVM_SYSTEM_DIR=$(pwd)/lvm.cfg
echo "y\n" | pvcreate -ff --uuid "CCmw0N-0We2-HzRS-jRZa-FkC7-NxTc-oAfvpX"\
--restorefile lvm.cfg/archive/VolGroup00_*.vg /dev/hda3
vgcfgrestore --file LVM.backs VolGroup00
# Hideously disty dependent!
if [ -e /etc/init.d/lvm ] ; then
/etc/init.d/lvm start
fi
echo
echo making LV /dev/VolGroup00/LogVol00 an ext3 partition.
mke2fs -j $blockcheck /dev/VolGroup00/LogVol00
echo
echo making LV /dev/VolGroup00/LogVol02 an ext3 partition.
mke2fs -j $blockcheck /dev/VolGroup00/LogVol02
echo
echo making LV /dev/VolGroup00/LogVol01 a swap partition.
mkswap $blockcheck /dev/VolGroup00/LogVol01
]]>

View File

@ -0,0 +1,46 @@
<![ CDATA [#! /bin/sh
# A script to create a minimal directory tree on the target hard drive
# and mount the partitions on it. Created at bare metal backup time by
# the Perl script make.fdisk.
# Copyright 2001 through the last date of modification Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
# WARNING: If your Linux system mount partitions across hard drive
# boundaries, you will have multiple "mount.dev.* scripts. You must
# ensure that they run in the proper order. The root partition should
# be mounted first, then the rest in the order they cascade. If they
# cross mount, you'll have to handle that manually.
# / is the mountpoint for tomsrtbt device /dev/hda3.
mkdir /target/
mount /dev/hda3 /target/
# /boot is the mountpoint for tomsrtbt device /dev/hda2.
mkdir /target/boot
mount /dev/hda2 /target/boot
mount | grep -i "/dev/hda"
]]>

View File

@ -0,0 +1,35 @@
<![ CDATA [#! /bin/sh
# A script to mount file systems on logical volumes. Created at bare
# metal backup time by the Perl script make.fdisk.
# Copyright 2006 through the last date of modification Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
mkdir -p /target/
mount /dev/VolGroup00/LogVol00 /target/
mkdir -p /target/home
mount /dev/VolGroup00/LogVol02 /target/home
mount | grep -i "/target"
]]>

View File

@ -0,0 +1,40 @@
<![ CDATA [#! /bin/sh
# A script to restore all of the data from an nfs mount. This is our final
# stage restore.
# Time-stamp: <2007-07-06 13:36:23 ccurley restore.all>
# Copyright 2000 through the last date of modification Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
export save="/mnt/save"
mount $save
cd /
gunzip -dc $save/tester.tar.gz | tar -xpkf -
rm /var/run/*.pid
lilo
]]>

View File

@ -0,0 +1,40 @@
<![ CDATA [#! /bin/sh
# A script to restore all of the data using ssh and bunzip2. This is
# our final stage restore.
# Copyright 2000 through the last date of modification Charles Curley.
# Time-stamp: <2007-07-06 13:36:42 ccurley restore.all.ssh>
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
save="/backs/tester/"
backup_server="charlesc"
cd /
ssh $backup_server "cat $save/tester.tar.bz2" | bunzip2 | tar -xpkf -
rm /var/run/*.pid
lilo
]]>

View File

@ -0,0 +1,130 @@
<![ CDATA [#! /bin/sh
# A script to restore the meta-data from the ZIP disk. This runs under
# tomsrtbt only after partitions have been rebuilt, file systems made,
# and mounted. It also assumes the ZIP disk has already been
# mounted. Mounting the ZIP disk read only is probably a good idea.
# Time-stamp: <2007-07-08 11:37:38 ccurley restore.metadata>
# Copyright 2000 through the last date of modification Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# 2007-07-08: We now force inittab to run level 3, which may be disty
# dependent. FHS compliance changes as well.
# 2005-08-03: We now use a relative path, so you can load from
# different places depending on the first stage system you are
# using. Also added some FC4 tricks, and some changes to better
# reproduce the permissions and ownerships.
# 2003 08 23: Oops: tar on tomsrtbt does not respect -p. Try setting
# umask to 0000 instead.
# 2003 02 13: Tar was not preserving permissions on restore. Fixed
# that.
# 2002 07 01: Went to bzip2 to compress the archives, for smaller
# results. This is important in a 100MB ZIP disk. Also some general
# code cleanup.
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
umask 0000
cd .. # Assume we are in /bin
zip=$(pwd)/data; # Where we find the tarballs to restore.
target="/target"; # Where the hard drive to restore is mounted.
ls -lt $zip/*.bz2 # Warm fuzzies for the user.
cd $target
# Restore the archived metadata files.
for archive in $( ls $zip/*.bz2 ); do
echo $archive
ls -al $archive
bzip2 -dc $archive | tar -xf -
done
# Build the mount points for our second stage restoration and other
# things.
# If you boot via an initrd, make sure you build a directory here so
# the kernel can mount the initrd at boot. tmp/.font-unix is for the
# xfs font server.
for dir in\
back\
dev\
initrd\
media\
mnt/dosc\
mnt/imports\
mnt/nfs\
mnt/zip\
proc\
selinux\
sys\
tmp/.font-unix\
var/cache/yum\
var/empty/sshd/etc\
var/lib/bare.metal.recovery\
var/lock/subsys\
var/log\
var/run\
var/spool\
; do
mkdir -p $target/$dir
done
for dir in mnt usr usr/share $(ls -d var/*) selinux usr/lib var\
var/cache/yum var/lock/subsys var/run var/empty/sshd/etc\
var/spool media ; do
chmod go-w $target/$dir
done
# Set modes
chmod 0111 $target/var/empty/sshd
chown root:lock $target/var/lock
chmod 775 $target/var/lock
chmod 711 $target/var/empty/sshd
chmod 700 $target/var/lib/bare.metal.recovery
# For Fedora. First two for xfs.
# chroot $target chown xfs:xfs /tmp/.font-unix
# chmod 1777 $target/tmp/.font-unix # set the sticky bit.
chmod 1777 $target/tmp
# Now install the boot sector. N.B: if you have libata IDE drive
# issues, it won't work. If it doesn't, use your rescue disk to do the
# same.
# chroot $target /sbin/lilo -C /etc/lilo.conf
chroot $target /sbin/grub-install /dev/hda
# Set the system to boot to run level 3 regardless of the current run
# level. Be sure to set it back to the normal value.
sed -i s/id:.:initdefault:/id:3:initdefault:/g $target/etc/inittab
df -m
]]>

View File

@ -0,0 +1,51 @@
<![ CDATA [#! /bin/sh
# A script to restore all of the data to tester via ssh. This is our final
# stage restore.
# Time-stamp: <2007-07-08 11:23:32 ccurley restore.tester>
# Copyright 2000 Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at http://www.fsf.org/
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
# 2007-05-22: Changes for FHS compliance. Removed commented out
# references to ZIP drives.
# 2006-04-14: Use the script ../scripts/get.target to determine the
# host name. This makes the script more general, and maybe we can run
# it from one place & determine the host name from the directory
# name.
# Get the host name of the computer to be backed up and other info.
. ../scripts/get.target
bunzip2 -dc $TARGET.tar.bz2 | ssh $host "umask 000 ; cd / ; tar -xpkf - "
# bunzip2 -dc $host.dos.$DATE.tar.bz2 | ssh $host "umask 000 ;\
# mount /mnt/dosc ; cd / ; tar -xpkf - "
# Note libata issue! We boot to /dev/sda, not /dev/hda, as IDE drives
# now show up as SCSI drives.
ssh $host "chown root:lock /var/lock ; grub-install /dev/sda"
# ; chown -R amanda:disk /var/lib/amanda
]]>

View File

@ -0,0 +1,302 @@
<![ CDATA [#! /bin/sh
# A script to save certain meta-data off to the boot partition. Useful for
# restoration.
# Time-stamp: <2007-07-06 13:38:29 ccurley save.metadata>
# Copyright 2000 through the last date of modification, Charles Curley.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA
# You can also contact the Free Software Foundation at
# http://www.fsf.org/
# 2007-05-22: Changes for FHS compliance. Removed commented out
# references to ZIP drives. Added a line to deal with the fact that
# libata (in newer kernels) maps IDE drives to SCSI device names, but
# not all rescue distributions use libata. So we have to change the
# device names from SCSI to IDE, e.g. /dev/sda to /dev/hda.
# 2006-03-26: had a deprecated option in the sort options; fixed that.
# 2005-09-09: Added a line to create a boot disk ISO in the ZIP drive.
# 2005-08-30: Modernized sub-shell calls, a few other tweaks.
# 2005-07-29: Fedora Core 4 mods. Name of the directory to be saved
# has to be last. Also, we now specify --numeric-owner so as to avoid
# UID problems when using some live CD systems. And we now save to
# /var instead of a mounted ZIP disk.
# 2005-02-19: Fedora Core 3 mods.
# 2003 01 08: We now age the output from rpm -VA to make back
# comparisons easier.
# The loop that creates directories now has the -p option for mkdir,
# which means you can create parents on the fly if they don't already
# exist.
# initrd is now in the list of directories to create automatically.
# We now exclude more stuff when building the tarballs.
# 2002 07 01: Went to bzip2 to compress the archives, for smaller
# results. This is important in a 100MB ZIP disk. Also some general
# code cleanup.
# 2002 07 01: The function crunch will tar and bzip2 the
# archives. This is cleaner than the old code, and has better safety
# checking.
# For more information contact the author, Charles Curley, at
# http://www.charlescurley.com/.
# Exclude: given a fully qualified path to an ambiguous file name,
# expand it to the base name plus, e.g. any version numbering in the
# base name. E.g. "/usr/lib/python*" becomes "python2.5" if that's
# what's in the directory. We then prepend "--exclude" and return
# it. Use it to prepare ambiguous excludes for crunch's benefit. If
# the file doesn't exist, we return nothing.
function exclude {
if [ -z "$1" ]; then # 0 length parameter check.
echo "-Parameter #1 is missing.-" # Also if no parameter is passed.
exit 1
else
if [ ! -e $1 ]; then
return
else
local file=$1
local target=$(ls -d $file)
echo "--exclude ${target##/*/}"
fi
fi
}
# Crunch: A function to compress the contents of a directory and put
# the archive onto the ZIP disk.
# The first parameter is the name of the archive file to be
# created. The backup location, $zip, will be prepended and the
# extension, "tar.bz2" will be appended.
# All following parameters will be taken as additional directories or
# files to be put into the archive.
function crunch {
if [ -z "$1" ] || [ -z "$2" ] # Checks if parameter #1 or #2 is zero length.
then
echo "-Parameter #1 or #2 is missing.-" # Also if no parameter is passed.
return 1
else
local file=$1 # The archive file to create
shift # Discard the file name
local dirs=$@ # The director[y|ies] to archive
local tarcmd="tar --numeric-owner -cjf" # The tar command.
local tarit="$tarcmd ${zip}/$data/$file.tar.bz2 $dirs"
echo $tarit
$tarit # do it!!
error=$? # Preserve the exit code
if [ $error != 0 ] # Did we fail?
then # Yes
echo "Tar failed with error $error"
echo $tarcmd ${zip}/$data/$file.tar.bz2 $dirs
exit $error # return tar's exit code as ours
fi
return 0 # For error testing if needed.
fi
}
# Begin the main line code
export data="data"; # Name of the data directory in the archive
export today=$(date +%Y%m%d); # Today's archive
export zip="/var/lib/bare.metal.recovery/${today}";
if [ -d ${zip} ] ; then
rm -r ${zip}
fi
mkdir -p ${zip}/metadata ${zip}/bin ${zip}/data
NEW=${zip}/metadata/rpmVa.txt # name for the rpm -Va output file.
# Now we save hard drive information. Run make.fdisk on each hard
# drive in the order in which it mounted from the root partition. That
# is, run it first on the hard drive with your root partition, then
# any hard drives that mount to the first hard drive, then any hard
# drives that mount to those. For example, if your root partition is
# on /dev/sdc, run "make.fdisk /dev/sdc" first.
# The reason for this is that make.fdisk produces a script to make
# mount points and then mount the appropriate partition to them during
# first stage restore. Mount points must be created on the partition
# where they will reside. The partitions must be mounted in this
# order. For example, if your /var and /var/ftp are both separate
# partitions, then you must mount /, create /var, then mount /var,
# then create /var/ftp. The order in which the script "first.stage"
# runs the mounting scripts is based on their time of creation.
# If necessary, put a line, "sleep 1" between calls to make.fdisk.
echo "Saving hard drive info"
# List all your hard drives here. Put them in the order you want
# things done at restore time.
for drive in sda ; do
make.fdisk /dev/${drive}
fdisk -l /dev/${drive} > ${zip}/fdisk.${drive}
done
# back up RPM metadata
echo "Verifying RPMs."
rpm -Va | sort -t ' ' -k 3 | uniq > ${NEW}
echo "Finished verifying RPMs."
echo -e "$(hostname) bare metal archive, created $(date)" > ${zip}/README.txt
uname -a >> ${zip}/README.txt
# Preserve the release information. Tested with Red Hat/Fedora, should
# work with SuSE, Mandrake and other RPM based systems. Debian
# equivalent, anyone?
for releasefile in $(ls /etc/*release*) ; do
# echo $releasefile
if [ -e $releasefile ] && [ ! -L $releasefile ] ; then
cat $releasefile >> ${zip}/README.txt
fi
done
echo "Building the ZIP drive backups."
# These are in case we need to refer to them while rebuilding. The
# rebuilding process should be mostly automated, but you never
# know....
ls -al /mnt > ${zip}/ls.mnt.txt
ls -al / > ${zip}/ls.root.txt
ls -al /var > ${zip}/ls.var.txt
cd /
# Build our minimal archives on the ZIP disk. These appear to be
# required so we can restore later on.
crunch usr.lib $(exclude /usr/lib/perl*)\
$(exclude /usr/lib/firefox*) $(exclude /usr/lib/gimp*) --exclude dri\
--exclude xorg --exclude gconv usr/lib
# crunch usr.share --exclude icons --exclude selinux\
# --exclude man --exclude doc --exclude locale --exclude X11\
# --exclude fonts --exclude gnome --exclude foomatic\
# --exclude gnome-applets --exclude man --exclude pixmaps usr/share
# crunch usr.share.locale /usr/share/locale/en_US/
# if [ -e /usr/share/fonts/default ]\
# && [ -e /usr/share/fonts/ISO8859-2 ]\
# && [ -e /usr/share/fonts/bitmap-fonts ]; then
# crunch usr.share.fonts /usr/share/fonts/default /usr/share/fonts/ISO8859-2 \
# /usr/share/fonts/bitmap-fonts
# fi
crunch root --exclude root/.cpan --exclude root/.mozilla --exclude root/down root
crunch boot boot
crunch etc --exclude etc/samba --exclude etc/X11 --exclude etc/gconf etc
crunch lib lib
crunch usr.sbin usr/sbin
# crunch usr.local usr/local
# crunch usr.libexec usr/libexec
crunch usr.kerberos usr/kerberos
crunch usr.bin --exclude usr/bin/emacs-x\
--exclude usr/bin/emacsclient --exclude usr/bin/emacs-nox --exclude\
usr/bin/gs --exclude usr/bin/pine $(exclude usr/bin/gimp-*)\
--exclude usr/bin/doxygen --exclude usr/bin/postgres --exclude\
usr/bin/gdb --exclude usr/bin/kmail --exclude usr/bin/splint\
--exclude usr/bin/odbctest --exclude usr/bin/php --exclude \
usr/bin/xchat --exclude usr/bin/gnucash --exclude usr/bin/pdfetex\
--exclude usr/bin/pdftex --exclude usr/bin/smbcacls\
--exclude usr/bin/evolution-calendar --exclude usr/bin/xpdf\
--exclude usr/bin/xmms usr/bin
crunch sbin sbin
crunch bin bin
crunch dev dev
# RH8. Fedora 1 puts them in /lib
# crunch kerberos usr/kerberos/lib/
# Now optional saves.
# arkeia specific:
# crunch arkeia usr/knox
# save these so we can use ssh for restore. *crack* for RH 7.0 login
# authentication.
# RH 8.0
# crunch usr.lib usr/lib/*crack* usr/lib/libz* usr/lib/libssl* usr/lib/libcrypto*
# Fedora 1
# crunch usr.lib usr/lib/*crack* usr/lib/libz* usr/lib/libwrap*\
# usr/lib/libk* usr/lib/*krb5* /usr/lib/libgss*
# Fedora 3
# crunch usr.lib usr/lib/*crack* usr/lib/libz* usr/lib/libwrap*\
# usr/lib/libk* usr/lib/*krb5* usr/lib/libgss*
# Fedora 7
# crunch usr.lib usr/lib/*crack*\
# usr/lib/libk* usr/lib/*krb5* usr/lib/libgss*
# Grub requires these at installation time.
crunch usr.share.grub usr/share/grub
# save the scripts we will use to restore.
cp -p /etc/bare.metal.recovery/* ${zip}/bin
echo "Testing our results."
find ${zip} -iname "*.bz2" | xargs bunzip2 -t
# Since we're doing system stuff anyway, make a boot disk ISO image
# suitable for burning. It uses the current kernel.
mkbootdisk --iso --device ${zip}/bootdisk.$(uname -r).iso $(uname -r)
# Recent kernels have incorporated a new ATA (IDE) hard drive
# driver. Because of this, parallel ATA drives now show up as SCSI
# drives, as serial ATA have always done. However, not all rescue
# distributions (e.g. finix) use this new driver. So the following
# line very carefully replaces "/dev/sda" with "/dev/hda". Use this as
# a template if you have multiple IDE hard drives.
# Note that there is no guaranteed mapping! Systems with multiple hard
# drives may have confusing mappings. Be sure to edit this line
# carefully. Check it if you add or remove a hard drive of any
# interface type to or from your system!
find ${zip} -type f | grep -v bz2$ | xargs sed -i 's|/dev/sda|/dev/hda|g'
du -hs ${zip}
df -m
]]>