Operating System - HP-UX
1753808 Members
7370 Online
108805 Solutions
New Discussion юеВ

cron&make_tape_recovery&redirect to afile

 
SOLVED
Go to solution
Cem Tugrul
Esteemed Contributor

cron&make_tape_recovery&redirect to afile

hi Gurusd,
i want to run with the command " make_tape_recovery -Av " from cron every 2 weks in a month so when this command runs also
want to generate a log file year_month_date_systemname.log at the same time to check what make_tape_recovery did..so i have written a script and put it to cron below
#!/usr/bin/ksh
sys_name=`hostname`
log_file=`date +"%y_%d_%m"
./opt/ignite/bin/make_tape_recovery|tee -a /tmp/$sysname$log_file.log
so norrmally script run on time and make_tape_recovery start but can not create the log file in /tmp directory...
only i see a file name .log and size=0

Please share your precious suggestions..
Greetings,
Our greatest duty in this life is to help others. And please, if you can't
3 REPLIES 3
Robert-Jan Goossens
Honored Contributor

Re: cron&make_tape_recovery&redirect to afile

Bill Hassell
Honored Contributor
Solution

Re: cron&make_tape_recovery&redirect to afile

A complete logfile with all the details you need is located in /var/opt/ignite/recovery/latest/recovery.log so all you need to do is copy that log someplace else if you need a history. make_tape_recovery doesn't work well with stdout and stderr redirects--there are some items that are missing, but are included in the above logfile. NOTE: The directory /var/opt/ignite/recovery/ contains the last 2 backup file history. The 'latest' directory is actually a symbolic link that will always point to the latest backup.

I'm concerned about your options though. Have you tried one of your Ignite tapes on a test machine? I would reommend using:

make_tape_recovery -I -v -x inc_entire=vg00 -a /dev/rmt/some-tape

You may also want to add -d "$(hostname) VG00 backup" and -t "Ignite backup for $(hostname) on $(date)" for complete documentation. In my Ignite backup script, I also test for a real tape (hint: mt -f /dev/rmt/some-tape status) and whether it is write-enabled (same command). i also test for a successful exit code, but this too is tricky. It will produce a non-zero exit if you exclude anything (including /cdrom for example) and will also complain if anything in /etc/fstab is not mounted. I modify fstab temporarily to remove the mountpoint for /cdrom (it uses the noauto option so it doesn't mount on reboot). And I email the result to the sysadmin mailbox when it runs.

After describing all this, maybe it would be easier just to look at the enclosed script.


Bill Hassell, sysadmin
Sridhar Bhaskarla
Honored Contributor

Re: cron&make_tape_recovery&redirect to afile

Hi,

Is this an exact copy-paste of your script?.

If so, there are syntax errors in your script.

log_file=`date +"%y_%d_%m"

Will give out errors as there is no closing 'tick'. It should have been

log_file=`date +"%y_%d_%m"`

The next line


./opt/ignite/bin/make_tape_recovery|tee -a /tmp/$sysname$log_file.log

This should have been

./opt/ignite/bin/make_tape_recovery|tee -a /tmp/${sys_name}${log_file}.log

as you used sys_name not sysname.

Since you are runnign it through cron, you may not want 'tee' in there. I would do

/opt/ignite/bin/make_tape_recovery -v -I -x inc_entire=vg00 -x exclude=/var/adm/crash -a /dev/rmt/0mn > /tmp/${sys_name}${log_file}.log 2>&1

to capture the standard error also.


-Sri
You may be disappointed if you fail, but you are doomed if you don't try