Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

back up script. 2

Status
Not open for further replies.

sirrom

Technical User
Jul 11, 2001
80
0
0
GB
I have written this backup script.
However I want to add an "eject tape" and also some kind of error catching to say if the backup has failed.
Can anyone point me in the right direction.

#!/usr/bin/ksh

LOGFILE=/backups/newlog

# Rewind the tape
mt -f /dev/rmt1.1 rewind

# Do the backup
for x in / /usr /var /home /live /test /ckp /jnl /work /apps

do
echo "Backing Up $x" >> $LOGFILE
backup -0 -u -f /dev/rmt1.1 $x
done

# End Message
echo 'Backup Completed on'`date` >> $LOGFILE

# THE END

Thanks in advance.
 
To eject the tape, you should be able to use:

mt -f <tape device> rewoff

which rewinds the tape and ejects it (essentially takes it 'offline').

As far as checking whether the backup is complete, consider writing the output of your backup to your $LOGFILE. Hope this helps.
 
Although not the best method, I find using || a quick and easy test. Do the following when executing your script

backup.sh || echo &quot;Backup Failed&quot; >> logfile

The second part of the command will only run if the first part fails.

Just as a quick side-note && is also useful

ls && ps

the second command will only run if the first is ok

so sdfksdfkdjf && ps wouldn't run at all.


Mike
 
Hi,

To check if the backup failed you could check the return code of the backup command:

backup -0 -u -f /dev/rmt1.1 $x
if [ $? != &quot;0&quot; ]
then
do some commands
fi


 
I've used the following script to eject a tape
tctl -f /dev/rmt0 rewind
tctl -f /dev/rmt0 offline

 
A lot of good suggestions so far... for rewind and ejecting
I use: tctl -f /dev/rmt0 rewoffl

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top