This is a simple backup script which dumps various directories on the / and /spare partitions of a set of Solaris servers. It is designed to make disaster recovery of the OS a little easier.
To customise this script for a different site, change the HOST_LIST to your set of Solaris hosts, set DIR_LIST to the directories you want to back up and change the TAPE_SRV and TAPE_DRV variables to the correct server and device for your site.
#!/bin/sh
#
HOST_LIST="prost wolf shadow bmw reynard toyota jordan jaguar honda"
DIR_LIST="/ /spare/export /spare/home /spare/opt /spare/usr /spare/var"
MAILLIST=unix.administrator@example.co.uk
totsize=0
archive=0
TAPE_SRV=wolf
TAPE_DRV=/dev/rmt/0un
echo "ProQuest Solaris Backup (private)"
echo ""
echo "Backup on"
date
echo ""
for host in $HOST_LIST
do
echo Backing up $host
for dir in $DIR_LIST
do
if [ $host = `hostname` ]; then
there=`ls $dir 2>/dev/null`
# echo $there
if [ -z "$there" ]; then
echo " no $dir on $host . Moving on ..."
else
dirsize=`/usr/bin/du -skd $dir | awk '{print $1}'`
totsize=`expr $totsize + $dirsize`
echo " Archive $archive ${host}:${dir} = $dirsize Kb ... running total = $totsize Kb"
ufsdump 0f ${TAPE_SRV}:${TAPE_DRV} $dir 2>/dev/null
archive=`expr $archive + 1`
fi
else
there=`rsh $host ls $dir 2>/dev/null`
# echo $there
if [ -z "$there" ]; then
echo " no $dir on $host . Moving on ..."
else
dirsize=`rsh $host /usr/bin/du -skd $dir | awk '{print $1}'`
totsize=`expr $totsize + $dirsize`
echo " Archive $archive ${host}:${dir} = $dirsize Kb ... running total = $totsize Kb"
rsh $host ufsdump 0f ${TAPE_SRV}:${TAPE_DRV} $dir 2>/dev/null
archive=`expr $archive + 1`
fi
fi
done
done
echo "Total Backup Size = $totsize Kb approx `expr $totsize / 1024 / 1024` Gb"
echo ""
echo "End of backup at"
date
echo ""
echo "Rewind and offline the tape"
rsh $TAPE_SRV mt -f $TAPE_DRV rewoffl
mailx -s "Solaris Backup Log" $MAILLIST < /home/colinbr/PROJECTS/BACKUPS/os_dump_logs/os_backup.log