Here's a backup script I wrote for the network of SunOS 4 machines that I
manage. I've put a decent amount of work in getting my backups to this
point, so I figured other people might find this script as useful as I have.
One note to make is regarding the variable "admin" set and used in the
script. Whoever "admin" is needs to have a line in their .rhosts allowing
root on the backup machine to use their account. In other words, if admin
is set to "user", and the backup script is being run on "hostA", the "user"
needs to have the line "hostA root" in his .rhosts file. If anybody can
think of a way to get around this when using dump/rdump/rsh/etc to do
backups, let me know. Also, if anybody notices any real problems with this
script, or has any suggestions for improvement, feel free to let me know
also. Enjoy!
... Shaug Evans *8)=
--
O'Shaughnessy Evans | phone: |"IBM, backard as ever, flogs a wierdo
Sys Admin, ARDFA | (805) 756-1706 | product called AIX, which they deny
Cal Poly State Univ.| fax: | stands for 'Ain't UNIX.' It's, ah,
San Luis Obispo, CA | (805) 756-1702 | UNIX-compatible?" -UNIX Sys Admin HB
### SCRIPT FOLLOWS:
#!/bin/sh
#set printexitcode
# written by O'Shaughnessy Evans (oevans) in April 1995.
# here's what "dumpscript" does:
# /, /usr, /home, /oracle, and /local are dumped from the NIS host of the
# machine this script is running on.
# /usr/local is dumped from fastlane.
# /home/data is dumped from gridlock.
# All dumps are stored on the tape drive of the NIS dumphost. Note that
# the usage of "mt" here assumes that this script is being run on that machine.
#
nishost=`ypwhich`
dumphost=airship
admin=oevans
TAPE=/dev/nrst0
REWTAPE=/dev/rst0
DUMP=/usr/etc/dump
RDUMP=/usr/etc/rdump
#
# options passed to dump...
#
#dumpopts=0cuabsdf
dumpopts=0cubsdf
logdir=/home/trans/$admin/admin/backup
blocksize=126
tapesize=6000
density=54000
tries="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"
#
# now we're going to back up the file systems
#
# If the current time is greater than $toolate, quit the script.
# This keeps the script from running all day if no tape was in the drive
# when the script was started (presumably by cron)
# don't start if after 8am, or some other time specified as the first
# command line option
if [ $1x = x ]; then
toolate=8
else
toolate=$1
fi
time=`date +%H`
if [ $time -ge $toolate ]; then
echo Good morning! Too late to start backups now.
exit 1
fi
echo date: `date`
echo -n "tape status: "
mt -f $REWTAPE status
echo dumphost: $dumphost
echo nishost: $nishost
echo Rewinding tape drive $REWTAPE
until mt -f $REWTAPE rew; do
echo Waiting for the backup drive to be ready.
sleep 3600
mt -f $REWTAPE rew
done
# So now there's a tape in. Should we continue?
time=`date +%H`
if [ $time -ge $toolate ]; then
echo Good morning! Too late to start backups now.
exit 1
fi
dump_filesystem()
{
fshost=$1
dumpfs=$2
echo "$fshost:$dumpfs... --------------------------------------------------="
for try in $tries; do
mt -f $TAPE asf $pos
if [ $? != 0 ]; then
mt -f $REWTAPE rew
sleep 300
continue
fi
if rsh $fshost -l $admin $RDUMP $dumpopts $blocksize $tapesize $density \
$dumphost:$TAPE $dumpfs; then
pos=`expr $pos + 1`
echo " DONE: $fshost:$dumpfs backed up successfully"
break
fi
done
# Dump away!Quote:}
pos=0
dump_filesystem fastlane /usr/local
dump_filesystem $nishost /oracle
dump_filesystem $nishost /local
until mt -f $REWTAPE rewoffl
do
mt -f $REWTAPE rewoffl
sleep 300
done