Operating System - HP-UX
1830216 Members
2032 Online
109999 Solutions
New Discussion

Auto day-end script problem

 
SOLVED
Go to solution
ajk_5
Frequent Advisor

Auto day-end script problem

Dear all,

I am working on the auto day-end process which will send email to system administrator if any backup problem. However my script doesn't work, how do I improve the script? Also, the backup_db_test.log has nothing inside, why is that?

Thanks !

Regards
Ajk

################################
# Perform Backup
################################

DATE=`date "+%b %d"`
ADMIN_EMAIL=administrator@abc.com
echo
echo "Backup directories: /dskdump/livedbbackup"
echo "----------------------------------------"
echo "Insert a new tape into tape driver"
echo
echo "Press ENTER to start backup"
read dummy

cd /dskdump/livedbbackup
$ISD_MENU/writelog.sh Backup Disk Dump DB Start
tar cvhf /dev/rmt/0m * >> $ISD_MENU/backup_db_test.log

if [`grep -i "cannot open" $ISD_MENU/isdadmin.log|wc -l` > 0]
then
grep "$DATE" $ISD_MENU/isdadmin.log|grep "cannot open"|mailx -s "Backup tape cannot open" $ADMIN_EMAIL
fi

$ISD_MENU/writelog.sh Backup Disk Dump DB End
date
echo "Backup Finished !"
echo Press ENTER to continue...
read dummy

6 REPLIES 6
ajk_5
Frequent Advisor

Re: Auto day-end script problem

The backup problem like tape error, no tape in tape drive, etc. Thanks.
Massimo Bianchi
Honored Contributor
Solution

Re: Auto day-end script problem

Hi,

1) Nothing in the backup_db_test.loog because you never defined in this script the variable ISD_MENU. Also, quote it with graphes.

$ISD_MENU/backup_db_test.log -->> ${ISD_MENU}/backup_db_test.log

So do for all variables used in the script, it's best.

2) examinate the return code from tar:

tar .....
RC=$?

0 -->> all is OK
>0 -->> some errors, check

3) you could think of using fbackup/frecover, it's faster and with better output. refer to man pages for use and to this forum for a list of config parameters...

Massimo
ajk_5
Frequent Advisor

Re: Auto day-end script problem

Dears,

I modify my script, but it is still not working and the log file has nothing inside. Please help. Thanks a lot!

Regards
Ajk

################################
# Perform Backup
################################
#/misadmin/isd_menu/baktp_time.sh
DATE=`date "+%b %d"`
ADMIN_EMAIL=administrator@abc.com
echo
echo "Backup directories: /dskdump/livedbbackup"
echo "----------------------------------------"
echo "Insert a new tape into tape driver"
echo
echo "Press ENTER to start backup"
read dummy

cd /dskdump/livedbbackup
/misadmin/isd_menu/writelog.sh Backup Disk Dump DB Start
tar cvhf /dev/rmt/0m * >> /misadmin/isd_menu/backup_db_test.log

RC=$?

if [RC > 0]
then
mailx -s "Backup Error!" $ADMIN_EMAIL
fi

#if [`grep -i "cannot open" $ISD_MENU/isdadmin.log|wc -l` > 0]
#then
#grep "$DATE" $ISD_MENU/isdadmin.log|grep "cannot open"|mailx -s "Backup tape cannot open" $ADMIN_EMAIL
#fi

/misadmin/isd_menu/writelog.sh Backup Disk Dump DB End
date
echo "Backup Finished !"
echo Press ENTER to continue...
read dummy
Steven E. Protter
Exalted Contributor

Re: Auto day-end script problem

These questions may seem silly:

How are you launching this script? It seems familiar. Is it by cron? What's the cron entry?

Has it ever worked?

Did you know that for cron launched scripts you need to build the environment for it, its not like a telnet or secure shell login session?

What if any errors is this script generating.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Massimo Bianchi
Honored Contributor

Re: Auto day-end script problem

Hi,
for debugging purpose, as the second line put a
"set -x"
so all commands will be printed.

Also: can you check with "ll" if the file and directory have proper permission for the user starting the commands ?

Maybe the file is empty because it is not writeable by the user.

Massimo
Mark Grant
Honored Contributor

Re: Auto day-end script problem

One thing you might have an issue with is

[ blah blah > 0 ]

This, should be [ blag blah -gt 0 ]

Never preceed any demonstration with anything more predictive than "watch this"