weekly.new 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. # start doing things
  3. TOBACKUP="albert:/"
  4. HOST=`hostname | sed 's/\..*//'`
  5. TAPEFILE=/dev/rfd0a
  6. LOGFILE=tar-out
  7. BLOCKING=20
  8. TAR_PART1="/usr/local/bin/tar clbfVM $BLOCKING"
  9. rm -f $LOGFILE
  10. mt -f $TAPEFILE rewind
  11. host=`echo $TOBACKUP | sed 's/:.*$//'`;
  12. fs=`echo $TOBACKUP | sed 's/^.*://'`;
  13. date=`date`;
  14. fsname=`echo $TOBACKUP | sed 's/\//:/g'`
  15. TAR_PART2="'Weekly backup of $fs on $host at $date' -C $fs ."
  16. echo Backing up $TOBACKUP at $date | tee -a $LOGFILE
  17. # Actually back things up.
  18. if [ $HOST != $host ] ; then
  19. rsh $host $TAR_PART1 $HOST:$TAPEFILE $TAR_PART2
  20. else
  21. sh -c "exec $TAR_PART1 $TAPEFILE $TAR_PART2"
  22. fi
  23. if [ $? -ne 0 ] ; then
  24. echo Backup of $TOBACKUP failed. | tee -a $LOGFILE
  25. echo mts at time of failure | tee -a $LOGFILE
  26. mts -t $TAPEFILE | tee -a $LOGFILE
  27. # I'm assuming that the tar will have written an empty
  28. # file to the tape, otherwise I should do a cat here.
  29. else
  30. echo $date > $fsname.lasttar
  31. fi
  32. sleep 60;
  33. mt -f $TAPEFILE rewind
  34. mt -f $TAPEFILE offl