Feb
06
Posted on 06-02-2008
Filed Under (Shell scripting) by Ravi Bhure

#!/bin/bash -x
# This script is useful for taking backup on Tape
# Tested on CentOS 3.8, CentOS 4.4
# For further info please login http://indianGNU.org or
# mail ravi <at> indianGNU.org

##### DECLARE AND INITIALIZE VARIABLES #####
### File with the full path names ###
DATE=`date +%m-%d-%g`
LOGDIR=/usr/local/admin/backup
BKDIR=/root/backup
TAPE1=$BKDIR/tape1
TAPE2=$BKDIR/tape2
TOC1=$LOGDIR/backup.$DATE/toc1
TOC2=$LOGDIR/backup.$DATE/toc2
ERR=$LOGDIR/backup.$DATE/errorlogs
GTAR=/bin/gtar
TAPE=/dev/st0
MT=/bin/mt
CP=/bin/cp
mkdir /usr/local/admin/backup/backup.$DATE

### Loop the the backup directory files ###
sleep 60
#$TIME > $TOC1
if [ -f “$TAPE1” ]; then
$MT -f $TAPE rewind;
$GTAR -cvf $TAPE -V “Tape1-Full.$DATE” $TAPE1
$CP $TAPE1 $TAPE2 $LOGDIR
for DIR1 in `cat $TAPE1`
do
$GTAR –exclude “simulation” -cvf $TAPE $DIR1 >> $TOC1 2>> $ERR
sleep 60;
done
$GTAR -cvf $TAPE $TOC1
$MT -f $TAPE rewoff
fi

### Loop the the backup directory files ###
sleep 180
#$TIME > $TOC2
if [ -f “$TAPE2” ]; then
$MT -f $TAPE rewind;
$GTAR -cvf $TAPE -V “Tape2-Full.$DATE” $TAPE2
for DIR2 in `cat $TAPE2`
do
$GTAR –exclude “simulation” -cvf $TAPE $DIR2 >> $TOC2 2>> $ERR
sleep 60;
done
$GTAR -cvf $TAPE $TOC2
$MT -f $TAPE rewoff
fi

#################################################
# Needed Additions to the backup script are: #
# Put table of contents on the end of the tape #
# Rotate through four sets of table of contents #
# in /usr/local/admin/backups #
#################################################

Thanks & Regards

Ravi Bhure 

Similar Posts:

Be Sociable, Share!
(0) Comments    Read More   
Post a Comment
Name:
Email:
Website:
Comments:


www.flickr.com
arunbagul's photos More of arunbagul's photos
Get Adobe Flash player
-->