UNIX admin cold backup script

#!bin/sh

#Backup program for Oracle servers directly connected to tape drives.

#In this case the drive is a DLT device which has already been

#configured. Make appropriate changes for portability.

oracle=`ls /etc/init.d | grep racl`

hostname=`/bin/hostname`

file="/var/tmp/$hostname"

#Shut down oracle databases

if [ -f /etc/init.d/$oracle ]

then

/etc/init.d/$oracle stop

else

echo "No Oracle start/stop script in /etc/init.d! Cannot backup without stopping Oracle--backup aborted." >> /var/tmp/dump.output

exit 1

fi

#Verify existence of target directories...

cat $file|while read dir

do

if [ -d $dir ]

then

#Do the dumps to non-rewinding device...

ufsdump 0lf /dev/nrst21 $dir || echo "ufsdump of $dir failed!" \

>> /var/tmp/dump.output

else

#Uh oh, no directory there!

echo "Unable to backup $dir, no such directory!" >> \

/var/tmp/dump.output

fi

#Make sure the dump REALLY worked...

if [ $? -eq 0 ]

then

echo "Dump of $dir successful!" >> /var/tmp/dump.output

else

echo "Dump of $dir failed!" >> /var/tmp/dump.output

fi

done

#Restart the databases:

/etc/init.d/$oracle start

if [ $? -eq 0 ]

then

echo "Oracle database started." >> /var/tmp/dump.output

else

echo "Oracle database failed to restart!" >> /var/tmp/dump.output

fi

#Let everyone know the score...

cat /var/tmp/dump.output | /usr/bin/mailx -s \

"Output of Oracle backup on $hostname" orabackups && \

rm /var/tmp/dump.output