Cover V12, I04
apr2003.tar

Listing 2 gd2nfs.ss

#!/bin/sh
# qd2nfs.ss: quick-n-dirty backup script for any old host.
# Use prior to upgrades 
# Author: Mark Foster

if ( test `id|sed 's/^uid=[0-9]*(\(.*\)) gid.*/\1/'` != 'root' ); then
   echo "Please execute this command as root!";
   exit;
fi
DATE=`date +%Y-%m-%d`
HOSTNAME=`hostname`
DESTBASE="/share/backup/$HOSTNAME/$DATE"
# If the archive folder is not there, create it
[ -d $DESTBASE ] || mkdir -p $DESTBASE

echo "Backup of $HOSTNAME commencing on $DATE"
cd /
# backup the "important" stuff

# Use arguments as our directory names
DIRS=$@
# Or these defaults if no args were supplied
if [ -z $DIRS ] ; then
   DIRS="etc usr/local"
fi

for d in $DIRS; do
   # Make sure directory even exists, or skip it
   if [ ! -d $d ] ; then
      echo "Sorry, directory $d does not exist!"
      continue
   fi
   # G is given path
   # F is fixed (path) to replace slashes w/ dashes
   G=$d
   F=`echo $G| sed -e 's/\//-/'` # flip any dashes to slashes
   SIZE=`du -sh $G | awk '{print $1}'`
   echo "Size of $G is $SIZE, do you want to archive? [y/n] "
   read answer
   : ${answer:=y}
   case $answer in
      [Yy]) echo "tar --totals -czf $DESTBASE/$F.tgz $G"
            tar --totals -czf $DESTBASE/$F.tgz $G
            ;;
         *) echo "It wasn't meant to be."
            ;;
   esac
done;
# EOF