Hi,
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
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