#!/bin/csh -f # file://dumpit # # Performs full level 0 backup of all mounted slices on hostname # specified as parameter $1 to hostname:device as specified in # parameter $2. If a colon (:) is not found in $2 the hostname the # script is running on is assumed to be the current hostname. If the # $2 is not specified at all then the TAPE environment variable is # used as the local host's tape device. If the TAPE variable is not # set then /dev/rmt/0n is used. # # Must have rsh access to/from both host being dumped and host # being dumped to. # # Some notes about rsh access: # # 1) Client hostname must be in /etc/host of server # # 2) Client hostname must be in $HOME/.rhosts # # 3) The hostname used in #2 must be the FIRST hostname tied # to the hostname's IP address in server's /etc/host. (e.g.) # # /etc/hosts # # 155.90.1.1 a # 155.90.1.2 b # 155.90.1.1 c # # You cannot use hostname c and have it work. You must use # hostname a instead in .rhosts. # # 4) Don't use /etc/hosts.equiv it is best left alone. It # confuses things. # # 5) Check your .profile/.login/.cshrc, etc.. for hangups like # stty commands, etc.. that require a terminal or interaction. # # Code around this by doing ?$TERM or similiar. # # # Modification Log: # # Name Date Why # ---- ---- --- # Kevin Inscoe (inscoe@iag.net) 12/26/97 Created orginal # # # Check to see if required parameter $1 is present if ( $1 == "" ) then /bin/echo "usage: dumpit hostname [dumphost:][tapedevice]" exit 1 endif # # Set environment and global variables # set ver = "1.0" setenv DUMPOPS "ul0bf 126" set IP = `ifconfig -a | grep inet | tail -1 | cut -f2 -d" "` set order = "/tmp/dumped.order" # # Announce ourselves # echo " " echo "DumpIt version" $ver echo " " # # Determine host being dumped, host being dumpted to and determine tape device # setenv DUMPHOST $1 if ( $2 == "" ) then setenv TAPEHOST `ifconfig -a | grep inet | tail -1 | cut -f2 -d" "` if ( $?TAPE ) then setenv TAPEDEV $TAPE else setenv TAPEDEV "/dev/rmt/0mn" endif else if ( `echo $2 | grep ":" | wc -l` == 0 ) then echo "dumpit: missing tape device" exit 1 endif setenv TAPEHOST `echo $2 | cut -f1 -d:` setenv TAPEDEV `echo $2 | cut -f2 -d:` endif # # Now find all mounted partitions on $DUMPHOST # echo "Checking for remote filesystems on" $DUMPHOST "..." set mount = `rsh $DUMPHOST df -ln | grep ufs | cut -f1 -d:` # # Now build file $DUMPHOST:/dumped.order and tar it to the tape as the second file # if ( -e $order ) /bin/rm -f $order /bin/touch $order /bin/echo "Dumped by DumpIt" $ver "on" `date` >> $order /bin/echo "Dumphost:" $DUMPHOST >> $order /bin/echo "Tapehost:" $TAPEHOST >> $order @ count = 2 foreach fs ( $mount ) @ count = $count + 1 /bin/echo $count $fs >> $order end # # Start the backup # echo " " echo " *** `echo $DUMPHOST` Backup - Level 0 ***" echo " " echo '--- REWINDING tape ---' (rsh -l root -n $TAPEHOST mt -f $TAPEDEV rew) echo '--- TARing scriptfile ---' (/bin/tar cvf - $0 | rsh -l root ${TAPEHOST} /bin/dd of=${TAPEDEV}) (rsh -l root -n $TAPEHOST mt -f $TAPEDEV eom) echo '--- TARing dumporder ---' (/bin/tar cvf - $order | rsh -l root ${TAPEHOST} /bin/dd of=${TAPEDEV}) foreach filesystem ( $mount ) echo '--- Dumping' $DUMPHOST':'$filesystem 'to tape ---' (rsh -l root $DUMPHOST /usr/sbin/ufsdump ${DUMPOPS} ${TAPEHOST}:${TAPEDEV} $filesystem) end # # rewind and offline the tape and clean up # /bin/rm -f $order (echo '--- REWINDING tape --- ') (rsh -l root -n $TAPEHOST mt -f ${TAPEDEV} rew) (rsh -l root -n $TAPEHOST mt -f $TAPEDEV off)