Q

Unix script to create database export via crontab

I need to find a Unix script that will run via crontab and create a full database export. The script I have attached runs OK via ./export.sh in a Unix shell (about two hours and is 22 GB in size), but when I run it via a crontab job, it takes 18 odd hours and is about three times the actual size. I would appreciate your help on this.

Hi Brian. I need to find a Unix script that will run via crontab and create a full database export. The script I have attached runs OK via ./export.sh in a Unix shell (about two hours and is 22 GB in size), but when I run it via a crontab job, it takes 18 odd hours and is about three times the actual size. I would appreciate your help on this. The script is below:
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:. 
  ; export PATH
ORACLE_SID=ris ; export ORACLE_SID
ORACLE_BASE=/oracle/app/oracle   
  ; export ORACLE_BASE
ORACLE_HOME=/oracle/app/oracle/product/10.2.0/RIS 
  ; export ORACLE_HOME
ORACLE_OWNER=oracle     ; export ORACLE_OWNER
ORACLE_GROUP=dba  ; export ORACLE_GROUP 
PATH=$PATH:$ORACLE_HOME/bin   ; export PATH
CLASSPATH=$ORACLE_HOME/DBCreate/oradev/classes/orapts.jar:
  $ORACLE_HOME/jdbc/lib/classes12.zip:$CLASSPATH
  ; export CLASSPATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH 
  ; export LD_LIBRARY 
ORAENV_ASK=NO 
TNS_ADMIN=$ORACLE_HOME/network/admin
  ; export TNS_ADMIN
TERM=vt100 ; export TERM
NLS_LANG=AMERICAN_AMERICA.US7ASCII  
  ; export NLS_LANG exp USERID="username/password@SID" 
  FILE=/oracle/app/oracle/dump/test.DMP 
  LOG=/oracle/app/oracle/dump/test.LOG COMPRESS=Y DIRECT=Y 
ROWS=Y CONSISTENT=Y FULL=Y # END
The only thing that I would change is to move $ORACLE_HOME/bin as the first directory in your PATH.

Next, I would run the above script in its own shell, mimicking what crontab does. To do so, use the following:

sh -x scriptname

This will execute the script in its own environment, not yours. You will often see things not obvious to you when you run the script yourself.

This was first published in August 2006

Dig deeper on Oracle database backup and recovery

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close