cancel
Showing results for 
Search instead for 
Did you mean: 

informix backup script help

SOLVED
Go to solution
George_Dodds
Honored Contributor

informix backup script help

Hi

I'm backing up my informix db to disk using the following script.

Since the backup file name has a static name in the onconfig file is there any way add a bit onto this script that will rename the backup file to the current date after the backup is finished?

Thanks

George

####################################################################
# script to backup Informix to disk
####################################################################
INFORMIXDIR=/opt/informix
export INFORMIXDIR
PATH=$INFORMIXDIR/bin:$PATH
export PATH
ONCONFIG=onconfig.svr2
export ONCONFIG
INFORMIXSERVER=svr2
#svr2 = pbs database
export INFORMIXSERVER
## Echo message to log file
echo "Archive Informix Online for $INFORMIXSERVER"
LEVEL=0
echo "$LEVEL"| ontape -s | head -100 > /tmp/ontapelogfile
6 REPLIES
George_Dodds
Honored Contributor

Re: informix backup script help

Here's the device entry in the onconfig file

TAPEDEV /infbackup/svr2backup.bak
Peter Godron
Honored Contributor
Solution

Re: informix backup script help

George,
how about:
mv /infbackup/svr2backup.bak /infbackup/`date +%Y%m%d%H`.bck

will result in 2007012608 (YYYYMMDDHH) format. I included the Hour, just in case you generate two backup files on the same day.
George_Dodds
Honored Contributor

Re: informix backup script help

Was not sure if the next step would need some sort of signal to let it know the backup had finished or not before it renamed the file.
Peter Godron
Honored Contributor

Re: informix backup script help

George,
although this is an old doc, you may find it useful :
http://www.oreilly.com/catalog/unixbr/chapter/ch14.html#83088

or for the whole chapter:
http://www.oreilly.com/catalog/unixbr/chapter/ch14.html
Steve Lewis
Honored Contributor

Re: informix backup script help

George,

you should really check the return code from the ontape command, in order to see if the backup worked.
Because your ontape command is in the middle of a series of pipes, its hard to do this without checking the online log file using onstat -m. Grep -i 'aborted'.

Anyway, just add one of the mv commands specified above to the end of your script after the ontape line.

Also do a 2>&1 on the end of the ontape line, to capture any stderr messages.

You should also rename /tmp/ontapelogfile to have a datetimestamp on the end, giving historical record of the backup success/failure status.
Don't store the backup messages in /tmp in case of cleardowns, you would lose them.

Steve
Ralph Grothe
Honored Contributor

Re: informix backup script help

> Was not sure if the next step would need some
> sort of signal to let it know the backup had
> finished or not before it renamed the file.

If the commands in the script are executed syncronous the execution of the next command
will only take place after the one before has finished execution.
However, if a predecessor process backgrounded the execution of pending commands will continue and not be blocked until the former's termination.
In such a case you can make use of the wait command.
Without arguments it will wait till all backgrounded process have finished.
But you can pass it the PID of a specific backgrounded process that the next command in the script should wait for.
The PID of the last backgrounded process is stored in the shell special variable $! for instance.
So you could add

wait $!

or better, if you have several backgrounded processes, store their PIDs in variables or an array immediately after they were backgrounded for later reference in various wait calls.
Madness, thy name is system administration