#!/bin/sh
#
# Backup script for DCSL client
#
# Run this as:
#
#	do_backup_tape tapehost tapedrive
#
# where tapehost is the machine with the tape drive on it (horton or
# yertle) and tapedrive is the name of the tape drive (/dev/nsa0).
#

PATH=/usr/sbin:/sbin:/usr/bin:/bin
export PATH

echo ">>> Backups for `hostname`"

DUMP=dump

#
# $1 is first command line argument.
# See if that is set to anything.  If it is set to something
# that should be the name of the machine with the tape drive.
# If no machine name is provided on the command line try to
# do the dump to a local tape drive.
#

if [ "$1" != "" ]; then
        DUMPWHERE=amanda@${1}\:
else
        DUMPWHERE=""
fi

#
# $2 is the second command line argument.
# See if that is set to anything.  If it is set to something
# that should be the name of the tape drive device on the
# remote machine.  If no tape drive device name is given on
# the command line set it to "/dev/nsa0" by default.
#

if [ "$2" != "" ]; then
        DUMPDEV=$2
else
        DUMPDEV=/dev/nsa0
fi

#
# Loop that sets the variable "partition" to the things
# after "in" one at a time running through the loop.
# So, in this case the commands between the curly braces
# get run six times.  The first time through the loop the
# shell variable "$partition" is set to be "/", the second
# time through the loop "$partition" is set to "/var", etc.
#

for partition in / /boot /var 
{
  echo ">>> Dumping $partition level 0"
  $DUMP 0f ${DUMPWHERE}${DUMPDEV} $partition 2>&1
  sleep 20
}
