1823143 Members
3474 Online
109647 Solutions
New Discussion юеВ

Re: backup script

 
SOLVED
Go to solution
musaddaq_2
Frequent Advisor

backup script

I have made an online backup script with DD cmd because my database supports raw device.
backup is going through but my worry is i cannot see the execution of it. i mean i want to make a logfile so that i can keep track of of each and every steps executed in my scripts.

Can anyone help me in this.
I will attach my smaple script with it.
7 REPLIES 7
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: backup script

It appears that you already have the echoes in place so all you need to do is redirect stdout and stderr. You can do that like this:

mybackup.sh > /var/tmp/backup.log 2>&1

or add these 2 lines at the top of your script

exec 1>/var/tmp/backup.log
exec 2>&1

You could decide to redirect stderr to a separate file as well.

I should also tell you that relying upon dd for you backups is not something that I would do. There is simply no error recovery nor error checking. You should really look at something like rman or better still DataProtector for this task.
If it ain't broke, I can fix that.
harry d brown jr
Honored Contributor

Re: backup script

Put

set -x

at the beginning

and then redirect the errors and STDOUT to a log file:

scriptname 2>&1 > logfilename

live free or die
harry d brown jr
Live Free or Die
musaddaq_2
Frequent Advisor

Re: backup script

Hello Mr. Stephenson and brown.
Thanks for your suggestions. It is making a backup log for me.

Thanks once again
renarios
Trusted Contributor

Re: backup script

Hi Musaddag,

Since you are using Oracle 9i, please consider using Oracle RMAN as backup and recovery tool. It's handy, FULLY supported by Oracle, uses less space and last but not least very free (gratis/gratuis).
With RMAN you can copy/clone database very easy and create online backups.

Cheers,

Renarios
Nothing is more successfull as failure
Basheer_2
Trusted Contributor

Re: backup script

Another way to get the log and all the cmds in the script it to

backup | tee -a backup.log > output.log
A. Clay Stephenson
Acclaimed Contributor

Re: backup script

The "tee" command will only capture stdin so the above command as written will miss stderr (and probably the most significant messages when things go wrong). The solution is to combine stderr and stdout BEFORE sending the output to "tee".


mybackup.sh 2>&1 | tee /var/tmp/backup.log

If it ain't broke, I can fix that.
Sandman!
Honored Contributor

Re: backup script

Musaddaq,

Your script does not include the shell in which its going to execute. If its the Korn shell and you need to turn on debugging then put the following lines at the top of your script:

=============================================
#!/bin/ksh
#
set -x
=============================================

After adding these lines to the top of the script schedule it through cron as follows:

mybackup.sh 2>&1 /var/tmp/mybackup.log

cheers!