3 # Run this script as root on the machine that has the tape drive, to make a
6 # If you give `now' as an argument, the dump is done immediately.
7 # Otherwise, it waits until 1am, or until the hour given as argument.
8 # Specify the hour as a number from 0 to 23.
10 # You must edit the file `backup-specs' to set the parameters for your site.
13 echo The backup must be run as root
,
14 echo or
else some files will fail to be dumped.
20 # This is undesirable -- rms.
21 # rsh albert /usr/local/adm/motd-backup-start
23 # Get the values of BACKUP_DIRS and BACKUP_FILES, and other variables.
26 # Maybe sleep until around specified or default hour.
28 if [ "$1" != "now" ]; then
29 if [ "$1"x
!= x
]; then
34 pausetime
=`date | awk '{hr=substr($4,1,2);\\
37 print 3600*(spec-hr)-60*mn;\\
39 print 3600*(spec+(24-hr))-60*mn; }' spec=$spec`
48 LOGFILE
=log
-`date | awk '{print $2 "-" $3 "-" $6}'`-full
49 HOST
=`hostname | sed 's/\..*//'`
50 TAR_PART1
="/usr/local/bin/tar -c --multi-volume --one-file-system --block=$BLOCKING --sparse --volno-file=$VOLNO_FILE"
51 #TAR_PART1="/usr/local/bin/tar -c --multi-volume --one-file-system --block=$BLOCKING "
53 # Make sure the log file did not already exist. Create it.
55 if [ -f $LOGFILE ] ; then
56 echo Log
file $LOGFILE already exists.
62 mt
-f $TAPE_FILE rewind
66 while [ $# -ne 0 ] ; do
67 host=`echo $1 | sed 's/:.*$//'`
68 fs
=`echo $1 | sed 's/^.*://'`
70 fsname
=`echo $1 | sed 's/\//:/g'`
72 TAR_PART2
="--listed=/etc/tar-backup/temp.level-0"
73 TAR_PART3
="--label='Full backup of $fs on $host at $date' -C $fs ."
75 echo Backing up
$1 at $date | tee -a $LOGFILE
77 # Actually back things up.
79 if [ $HOST != $host ] ; then
80 # Removed 2>&1/dev/null cruft since that's incorrect sh syntax.
81 rsh $host mkdir /etc
/tar-backup > /dev
/null
2>&1
82 rsh $host rm -f /etc
/tar-backup/temp.level
-0
83 rsh $host $TAR_PART1 -f $HOST:$TAPE_FILE $TAR_PART2 $TAR_PART3 2>&1 | tee -a $LOGFILE
85 mkdir /etc
/tar-backup > /dev
/null
2>&1
86 rm -f /etc
/tar-backup/temp.level
-0
87 # Using `sh -c exec' causes nested quoting and shell substitution
88 # to be handled here in the same way rsh handles it.
89 sh
-c "exec $TAR_PART1 -f $TAPE_FILE $TAR_PART2 $TAR_PART3" 2>&1 | tee -a $LOGFILE
91 if [ $?
-ne 0 ] ; then
92 echo Backup of
$1 failed.
| tee -a $LOGFILE
93 # I'm assuming that the tar will have written an empty
94 # file to the tape, otherwise I should do a cat here.
96 if [ $HOST != $host ] ; then
97 rsh $host "mv -f /etc/tar-backup/temp.level-0 /etc/tar-backup/$fsname.level-0" 2>&1 | tee -a $LOGFILE
99 mv -f /etc
/tar-backup/temp.level
-0 /etc
/tar-backup/$fsname.level
-0 2>&1 | tee -a $LOGFILE
102 $TAPE_STATUS | tee -a $LOGFILE
107 # Dump any individual files requested.
109 if [ x
!= "x$BACKUP_FILES" ] ; then
112 TAR_PART2
="--listed=/etc/tar-backup/temp.level-0"
113 TAR_PART3
="--label='Full backup of miscellaneous files at $date'"
115 mkdir /etc
/tar-backup > /dev
/null
2>&1
116 rm -f /etc
/tar-backup/temp.level
-0
118 echo Backing up miscellaneous files
at $date | tee -a $LOGFILE
119 # Using `sh -c exec' causes nested quoting and shell substitution
120 # to be handled here in the same way rsh handles it.
121 sh
-c "exec $TAR_PART1 -f $TAPE_FILE $TAR_PART2 $TAR_PART3 \
122 $BACKUP_FILES" 2>&1 | tee -a $LOGFILE
123 if [ $?
-ne 0 ] ; then
124 echo Backup of miscellaneous files failed.
| tee -a $LOGFILE
125 # I'm assuming that the tar will have written an empty
126 # file to the tape, otherwise I should do a cat here.
128 mv -f /etc
/tar-backup/temp.level
-0 /etc
/tar-backup/misc.level
-0 2>&1 | tee -a $LOGFILE
130 $TAPE_STATUS | tee -a $LOGFILE
132 echo No miscellaneous files specified
| tee -a $LOGFILE
136 mt
-f $TAPE_FILE rewind
137 mt
-f $TAPE_FILE offl
139 echo Sending the dump log to
$ADMINISTRATOR
140 cat $LOGFILE | sed -f logfile.
sed > $LOGFILE.tmp
141 /usr
/ucb
/mail -s "Results of backup on `date`" $ADMINISTRATOR < $LOGFILE.tmp
143 # This is undesirable -- rms.
144 #rsh albert /usr/local/adm/motd-backup-done &