Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron settings to take a database backup

Status
Not open for further replies.

nilin

Programmer
Aug 14, 2003
26
Hello,
I am having HP-UX 10.2 , and wanted to set a cron job
to take a database backup,
Please help me with example.
Thanks in advance
Sandeep
 
Hi Sandeep,

which database backup do you want to start ? You should have a complete script which sets the environment variables you need for contacting the DB (for Oracle the ORACLE_HOME & ORACLE_SID) and the backup script itselfs. This is necccesary because crontab does not make an su - for normal.
Hth
Uwe
 
Hi appi,
Thanks for reply,
I am using Informix as Database,
I wanted to take dbexport backup, this is a simple command
in Informix to take database backup, which i knows,
but since i am new to scripting i don't know how to setup
the cron & crontab jobs,
I just needs steps to do this in HP-Unix O.S.
may be with simple script example - any script will do
i will change it to my dbexport script.

Thanks
Sandeep
 
Hi Sandeep,
okay, no prob - i know Informix too.
First you need to create a scriptfile wihich includes the dbexport. It should look like this:

#!/bin/ksh
# setting environment
export INFORMIXDIR=<your INFORMIXDIR>
export INFORMIXSERVER=<your INFORMIXSERVER>
export PATH=$PATH:$INFORMIXDIR

# running the command
$INFORMIXDIR/bin/dbexport <database>


than you need to create a crontab job but its neccesary that the user is included in /var/adm/cron/cron.allow
than you can start crontab (on tzhe prompt) and put in the job:

crontab -e ---- starts Editor for crontab

00 02 * * * /usr/local/bin/backupDB.sh 1>/usr/local/bin/backup.txt 2>&1


This command is in one line. The entries mean the following:
First two are Minutes and Hours of starttime, if different minutes or hours needed put them with comma
Next three are monthday (1-31 or * for all)
month (1-12 or * for all)
weekday (0-6 for Sunday to Saturday or *)
the next is the complete Path to your backup script
and 1>xxxx.txt 2>&1 means that all messages should written in the named file and all errors from Error-Out also in the same file.

btw, why you start with dbexport ? Is it possible for you to set up ISM for using onbar ? With that you can perform a hotbackup for better restore of even one Tablespace.

regards
Uwe


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top