Error in Backup Script

Taking care of your Linux box.
telenor
Havaldaar
Posts: 104
Joined: Tue Mar 29, 2005 11:08 am

Error in Backup Script

Postby telenor » Thu Aug 26, 2010 11:27 am

I made a following script for Data Backup on Tape Device, but script is not working fine. Please review the script

#################################

DAT=`date +%d_%m_%Y`
BDIR="/home/userid/$DAT"
TD="/dev/st0"
LOGS="/scripts/$DAT"

clear
echo | tee $LOGS

if mt -f $TD status | grep 41010000 > /dev/null
then
echo "Tape Found in DRIVE" | tee -a $LOGS

mt -f $TD load

if test $? = 0
then
echo "Tape loaded successfully"
echo | tee -a $LOGS

SIZE=`du -sh $BDIR | cut -f1`
echo "Size of $DAT Directory: $SIZE" | tee -a $LOGS
echo | tee -a $LOGS

time_start=`date +%s`
echo "BACKUP START at" `date` | tee -a $LOGS
echo

tar -cvp -f $TD $BDIR | tee -a $LOGS

mt -f $TD offline
if test $? = 0
then
echo "Tape unloaded sucessfully"
else
echo "Unloading Tape failed. Check it manually"
fi

echo
fi
else
echo " Cartridge not found in DRIVE1"
echo " Please Insert Cartridge in DRIVE1 Only"
sleep 6
exit 2
fi
echo | tee -a $LOGS

time_end=`date +%s`
time_elapsed=$((time_end - time_start))
echo "BACKUP FINISHED at" `date` | tee -a $LOGS
echo | tee -a $LOGS
echo "Backup Completed Time $(( time_elapsed / 60 )) Minute $(( time_elapsed % 60 )) Seconds" | tee -a $LOGS
echo | tee -a $LOGS

echo
read -p "Press Enter to continue.........." readDamKey

exit 0

#################################


I m using Oracle Enterprise Linux with BASH Shell

lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Postby lambda » Sun Aug 29, 2010 2:46 pm

are we supposed to guess the error?
Watch out for the Manners Taliban!
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?

ranatanveer
Subedar
Posts: 355
Joined: Sat May 07, 2005 11:54 am
Location: Lahore
Contact:

Postby ranatanveer » Thu Sep 30, 2010 1:26 am

:)

post the error you are getting.
Regards

Rana Tanveer
+923224194457
Linux Student

For Affordable Web Development http://www.affordableprogrammers.com
http://www.qualityprogrammers.com


Return to “Administration”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest