On 13-Mar-00 at 11:32:12 John Horne wrote:
>
> Thanks should go to Dave Foster for the backup scripts he sent me as well.
>
I received a few requests for the backup scripts, and Dave kindly said it was
okay to distribute them. So I have attached them to this message.
John.
--------------------------------------------------------------------------
John Horne, University of Plymouth, UK Tel: +44 (0)1752 233914
E-mail: jhorne@plymouth.ac.uk
Finger for PGP key: john@jhorne.csd.plymouth.ac.uk
#!/bin/csh
#
# BACKUP_SYSTEMS 6-25-99 DSFoster
#
# Script to automate the backup of Sun systems within the BIAL.
# Uses RSH to invoke "system_dump" utility on remote systems,
# and calls this script directly for local system.
#
#====================================
# Host definitions and tapes-per-host
#====================================
set BIAL_HOSTS = ( bial1 bial5 bial6 bial7 bial8 ) # All hosts to be backed
up
set TAPES_PER_HOST = ( 1 1 2 1 2 ) # Dump tapes per host
set TAPE_HOST = bial5 # Host with tape drive
set LOCAL_HOST = `/usr/bin/hostname` # Local host
set BIN_DIR = /usr/local/bin # Location of scripts (SYSTEM_DUM
P)
set BACKUP_TYPE = "Full" # Default to full level-0 dumps
while ( $#argv )
switch ( $argv[1] )
case "-h":
echo " "
echo " Usage: $0 [-i] [-r rhost]"
echo " "
echo " -i : Incremental backups for all systems"
echo " -r : Use tape drive connected to rhost (default is $TAPE_
HOST)"
echo " "
exit 0
breaksw
case "-i": # Perform incremental dumps
set BACKUP_TYPE = "Incremental"
breaksw
case "-r": # Remote tape host specified
set $TAPE_HOST = $argv[1]
breaksw
default:
breaksw
endsw
shift
end
# Backup each host
@ hosts = 1
while ( $#BIAL_HOSTS != 0 )
if ( $BACKUP_TYPE == "Incremental" ) then
@ tapes = 1 # Incremental dumps so just one tap
e!
@ incr = 1
else
@ tapes = ${TAPES_PER_HOST[1]} # Number of tapes to dump
@ incr = 1
endif
# Backup each tape for current host
while ( $incr <= $tapes )
echo " "
set prompt_user = "No"
if ( $BACKUP_TYPE == "Incremental" ) then
if ( $hosts == 1 ) then
echo "Put tape labelled [ Incremental System Dumps: All Systems
] in tape drive"
set dump_level = 5
set prompt_user = "Yes"
endif
else
echo "Put tape labelled [ System Dumps: $BIAL_HOSTS[1] # $incr ] in
tape drive"
set dump_level = 0
set prompt_user = "Yes"
endif
if ( $prompt_user == "Yes" ) then
set input = "retry"
while ( $input == "retry" )
echo -n "Perform these system dumps? (y/n) "
set input = $<
switch ( $input )
case [yY]:
breaksw
case [nN]:
goto NEXT_TAPE
breaksw
default:
set input = retry
breaksw
endsw
end
echo " "
endif
if ( $BACKUP_TYPE == "Incremental" ) then
set host_modifier = "-m all"
else if ( $incr > 1 ) then
set host_modifier = "-m $incr"
else
set host_modifier = ""
endif
if ( ${BIAL_HOSTS[1]} == $LOCAL_HOST ) then
echo "$BIN_DIR/system_dump $host_modifier -r $TAPE_HOST $dump_level"
$BIN_DIR/system_dump $host_modifier -r $TAPE_HOST $dump_level
else
echo "rsh ${BIAL_HOSTS[1]} $BIN_DIR/system_dump $host_modifier -r $T
APE_HOST $dump_level"
rsh ${BIAL_HOSTS[1]} $BIN_DIR/system_dump $host_modifier -r $TAPE_HO
ST $dump_level
endif
NEXT_TAPE:
@ incr += 1
end
# Get next elements in wordlists
@ hosts += 1
shift BIAL_HOSTS
shift TAPES_PER_HOST
end
----------
#!/bin/sh
#
# SYSTEM_DUMP 7-21-99 DSFoster
#
#-------------------------------------------------------------------------------
# Script to assist in performing filesystem dumps.
# NOTES:
#
# The "dumpsched" variable is a list of default dump levels Sunday
# through Saturday.
#
# The file systems will be dumped in the order of the variable "disks"
#
# general usage: system_dump
#
# Non-interactive usage: system_dump <level>
#
# for an unrecorded dump: system_dump special
#
#-------------------------------------------------------------------------------
#
# Modifications:
#
# 3-16-97 DSF Created.
# 9-19-97 DSF Added "-h host" option to specify target hostname.
# 10-19-98 DSF Add "-m modifier" option to allow multiple dumps from
# single machine.
# 7-21-99 DSF Ported to NCMIR lab, new hosts! For now make sure
# we're on a Solaris system (todo: support SGI/DEC/??).
#
if ( test "`uname -r | cut -d. -f 1`" != "5" ) then
echo "Not a Solaris system"
exit
fi
# Allow multiple dumps from same host by modifying hostname using
# -m parameter (so "host" becomes "host_2" for "-m 2".
case $1 in
-m) host_modifier=$2
shift
shift;;
*) host_modifier="none"
esac
# Allow user to specify remote dump host as argument
case $1 in
-r) dumphost_arg=$2
shift
shift;;
*) dumphost_arg="none"
esac
case $1 in
-h) echo " "
echo " Usage: system_dump [-m modifier] [-r rhost] [ [0-9] | [
special] ]"
echo " "
echo " modifier : modify hostname by adding _modifier (eg. _2
)"
echo " rhost : remote target host with tape drive"
echo " 0-9 : dump-level (0=full)"
echo " special : do unrecorded dump"
echo " "
echo " Arguments must appear in order shown"
echo " "
exit;;
*)
esac
# commands and constants
#hostname="/usr/ucb/hostname"
hostname="/usr/bin/hostname"
whoami="/usr/ucb/whoami"
# Get dumphost info (EDIT FOR LOCAL SITE). Modify hostname by adding "_#"
# if specified on command-line. This allows for multiple dumps from the
# same host. Save original hostname.
orig_host=`$hostname`
if ( test $host_modifier = "none" ) then
host=`$hostname`
else
host=`$hostname`_$host_modifier
fi
case $host in
dim) disks="/ /usr /var /usr/openwin /opt /opt2"
dumphost="proteus"
device="4mm"
dumpsched="0 0 0 0 0 0 0";;
# host2) disks="???"
# dumphost="host-with-tape"
# device="8mm"
# dumpsched="na 0 na 5 na 3 na";;
*) echo `basename $0`: Unexpected hostname: $host
exit;;
esac
# Enable remote host specified as argument
if ( test $dumphost_arg != "none" ) then
dumphost=$dumphost_arg
fi
echon()
{
/usr/ucb/echo -n "$*"
}
getlevel()
{
# get default dump level based on dump_schedule:
day=`date +%w`
while ( test $day -gt 0 )
do
shift
day=`echo $day-1 |bc`
done
default=$1
# query to make sure of level:
case $default in
[0-9]) echon "Dump Level (0-9) [$default]: ";;
*) echon "Dump Level (0-9): ";;
esac
read ans
case x$ans in
x[0-9]) level=$ans;;
x) level=$default;;
*) echo $ans is an invalid value for dump_level.; exit;;
esac
}
# make sure user has root access:
user=`/usr/ucb/whoami`
if (test $user != "root" ) then
echo `basename $0`: Sorry. You must be root to dump filesystems.; exit
fi
# get date:
echo " "
echo Today is `date "+%B %d, %Y (%A)"`
update=u
# get and verify dump level:
case x$1 in
x[0-9]) level=$1;;
xspecial) unset update; getlevel $dumpsched;;
x) getlevel $dumpsched;;
*) echo $1 is an invalid value for dump_level.; exit;;
esac
# Set dump parameters based on physical dump device.
case $device in
4mm) dumpparams="${update}cbf 126"
dumpdevice="/dev/rmt/0";;
# 8mm) dumpparams="${update}f"
# dumpdevice="/dev/rmt/0m";;
*) echo Invalid device option: $device.; exit;;
esac
# dump the filesystems:
echo " "
echo "--------------------------------------------------------------------"
echo "Preparing for level $level dump to $device tape drive on $dumphost"
echo "--------------------------------------------------------------------"
echo " "
starttime=`date "+%I:%M %p on %A, %B %d, %Y"`
if (test $orig_host != $dumphost) then
access=`rsh $dumphost $whoami`
echo Local access is $access
if (test $access != root) then
echo No root access to remote host $dumphost. ;exit
else
echo Root access to $dumphost verified
fi
echon Making sure tape is rewound...
rsh $dumphost mt -f $dumpdevice rewind
echo done
for disk in $disks
do
echo DUMPING ${disk}...
ufsdump ${level}${dumpparams} ${dumphost}:${dumpdevice}n ${disk}
done
echon Rewinding tape...
rsh $dumphost mt -f $dumpdevice rewoffl
echo done
echo Ejecting tape...done
else
echon Making sure tape is rewound...
mt -f $dumpdevice rewind
echo done
for disk in $disks
do
echo DUMPING ${disk}...
ufsdump ${level}${dumpparams} ${dumpdevice}n ${disk}
done
echon Rewinding tape...
mt -f $dumpdevice rewoffl
echo done
echo Ejecting tape...done
fi
stoptime=`date "+%I:%M %p on %A, %B %d, %Y"`
echo " "
echo "dump started: $starttime"
echo "dump ended: $stoptime"
echo " "
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Foster National Center for Microscopy and Imaging Research
Programmer/Analyst University of California, San Diego
dfoster@ucsd.edu Department of Neuroscience
(858) 534-7968 http://www-ncmir.ucsd.edu/
[All opinions expressed are mine -- duh]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
End of MIME message
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:14:04 CDT