Error in Backup Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error in Backup Script
# 1  
Old 08-25-2010
Error in Backup Script

Hi,

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

Code:
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

Moderator's Comments:
Mod Comment Use code tags please.
# 2  
Old 08-25-2010
Mind sharing in detail what is not working well before one has to check the whole code? Might be easier, ty.
# 3  
Old 08-25-2010
... and which Operating System and Shell you are using.

First impressions are of syntax errors. For example there are 3 "if" but only 2 "fi".
There probably should be a "fi" just before the "else".
Indentation is your friend.


To check for syntax errors before running a script (assuming ksh):

Code:
ksh -n scriptname


Though in your case it probably doesn't matter it is normal to use the "no rewind" device in "mt" commands.
Not sure what sort of tape deck this is but I have never seen a "mt load" command and have never needed a "mt offline" command. The "mt status" and "mt rewind" are usually what you need.
# 4  
Old 08-26-2010
I am using Oracle Enterprise & script based on bash shell
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

2. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

3. Shell Programming and Scripting

Need help in creating file restoration script from a backup script.

Hi all i am struggling in creating a restore of env files while doing applications clone. the first file i created for copying the important configurations file which is running perfect now for reverting the changes i mean when i am restoring these files to its original places i have to do... (7 Replies)
Discussion started by: javeedkaleem
7 Replies

4. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

5. Shell Programming and Scripting

Syntax error with automated backup script

Hi guys, I'm new to Linux and dont know much of scripting..there's an automated backup script that will backup the database from a location to another location between servers..it was created by another person and I tried to understand it somewhat.. I hope the script first checks if mount... (4 Replies)
Discussion started by: koolhart
4 Replies

6. UNIX for Dummies Questions & Answers

Syntax error with backup script

Hi guys, I'm new to Linux and dont know much about scripts..there's an backup script that will backup the database from a location to another location between servers..it will run automatically by adding it to crontab...it was created by another person and I tried to understand it somewhat.. ... (1 Reply)
Discussion started by: koolhart
1 Replies

7. AIX

backup script failed with error '0403-005 Cannot create the specified file'

In AIX 5.1, a daily run script that backing up oracle data failed yesterday with following errors: The Tivoli backup of DBPROD failed. What could be the issue, OS, backup or Oracle? (3 Replies)
Discussion started by: jalite19
3 Replies

8. Shell Programming and Scripting

error in sh script while copy files to a backup directory

I am trying to copy files from one directory to another using shell script. Can anyone please troubleshoot the code. thanks in advance... #!C:\Shell\sh.exe files_dir="C:\Documents and Settings\scripts\files" backup_dir="C:\Documents and Settings\scripts\ztest" echo cding to... (2 Replies)
Discussion started by: sureshcisco
2 Replies

9. Filesystems, Disks and Memory

Tru64 backup error

Running Tru64 and the library is MSL6000. Also, running Sybase. Performing tape library inventory. No values returned by robot list command. ERROR: Unable to perform preliminary inventory. Job aborting. Wed May 13 07:00:08 2009: DB_tape_backup process completed. I'm getting this error on... (0 Replies)
Discussion started by: Troberts50
0 Replies

10. UNIX for Advanced & Expert Users

Shell script on Oracle hot backup got an error

Hi Unix Shell Script Expert, We have a robust shell script (from old time) for our 9i database hot backup but generated error: Shell Script Content: #check for auto log mode and redirect as early as possible # autolog_enable $AUTOLOG_MODE $ORACLE_BASE/${ORASID_LOW}log/cron_hotbackup.log... (1 Reply)
Discussion started by: oradbus
1 Replies
Login or Register to Ask a Question