#

# Export full database shell script

#

#! /bin/ksh

# Usage "exp_db SID"

# Pre-requisites

# 1. Make sure that you have a parameter file

# 2. Create all directory structures

# Check for usage.

#-------------------------------------------------------------------------------

if [ "$#" -ne 1 ]

then

echo "exp_db"

echo "Purpose: For performing full database export"

echo "Usage: exp_db {SID}"

echo "{SID} Database SID"

echo "want to export."

echo "Exiting."

exit 1

fi

#-------------------------------------------------------------------------------

# Set your site/db specific information here:

# Set ORACLE_HOME

#-------------------------------------------------------------------------------

SID=$1 ; export SID

ORACLE_SID=$1 ; export ORACLE_SID

ORAENV_ASK=NO ; export ORAENV_ASK

HOST=`/bin/uname -n` ; export HOST

#ORACLE_HOME=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx OR run below script

. ~oracle/SH_ORASETUP

PATH=$PATH:$ORACLE_HOME/bin; export PATH

MAIL=/usr/ucb/mail

DISTLIST=oradba@questam.com

#-------------------------------------------------------------------------------

# The following environment variables are internal to this script.

# You can customize these.

#-------------------------------------------------------------------------------

LOGFILE=~oracle/admin/${SID}/exp/${SID}_exp_db.log

EXPLOG=~oracle/admin/${SID}/exp/e_${SID}_exp_db.log

DMPFILE=~oracle/admin/${SID}/exp/${SID}_exp_db.dmp

PARFILE=~oracle/admin/${SID}/exp/exp_db_${SID}.par

#-------------------------------------------------------------------------------

# Put Startup info into logfile:

#-------------------------------------------------------------------------------

MSG="

\n------------------------------------------------------------------------

\nOracle Database Export of $1

\nExport begun at `date`

\nORACLE_HOME = $ORACLE_HOME

\nORACLE_SID = $ORACLE_SID

\n------------------------------------------------------------------------

"

echo $MSG > $LOGFILE

#

#-------------------------------------------------------------------------------

# Remove previous export file

#-------------------------------------------------------------------------------

echo "Removing old export file:" >> $LOGFILE

echo "rm ${DMPFILE}.gz.save" >> $LOGFILE

rm ${DMPFILE}\.gz.save

echo "Renaming old export file:" >> $LOGFILE

echo "mv ${DMPFILE}.gz ${DMPFILE}.gz.save" >> $LOGFILE

mv ${DMPFILE}\.gz ${DMPFILE}\.gz.save

#-------------------------------------------------------------------------------

# Begin database export with compression

#-------------------------------------------------------------------------------

echo "Create a FIFO (named pipe):" >> $LOGFILE

echo "/usr/sbin/mknod $DMPFILE p" >> $LOGFILE

/usr/sbin/mknod $DMPFILE p

wait 3

echo "Compress file while exporting:" >> $LOGFILE

echo "$HOME/bin/gzip < $DMPFILE > $DMPFILE.gz &" >> $LOGFILE

$HOME/bin/gzip < $DMPFILE > $DMPFILE\.gz &

echo "Begin export:" >> $LOGFILE

echo "exp file=$DMPFILE log=$EXPLOG parfile=$PARFILE" >> $LOGFILE

exp file=$DMPFILE log=$EXPLOG parfile=$PARFILE

wait 3

cat $EXPLOG >> $LOGFILE

#-------------------------------------------------------------------------------

# Clean up files that are no longer needed

#-------------------------------------------------------------------------------

echo "Cleaning up temporary files:" >> $LOGFILE

echo "rm $DMPFILE" >> $LOGFILE

rm $DMPFILE

# Note: $EXPLOG is removed at the end of the script

echo "rm $EXPLOG" >> $LOGFILE

#-------------------------------------------------------------------------------

# That's it. Write wrap up info to logfile and exit the shell.

#-------------------------------------------------------------------------------

MSG="

\n------------------------------------------------------------------------

\nOracle Database Export of $1

\nExport finished at `date`

\n------------------------------------------------------------------------

"

echo $MSG >> $LOGFILE

#

if [ "`tail -1 $EXPLOG`" = "Export terminated successfully without warnings." ]

then

$MAIL -s"${SID} Export - Successful" $DISTLIST < $LOGFILE

else

$MAIL -s"Warning: ${SID} Export - Failure" $DISTLIST < $LOGFILE

fi

#

# Clean up files that are no longer needed

rm $EXPLOG

#

exit

##################### END of export shell script ##########################

Parameter file : exp_db_SID.par

----------------------------------------------cut below ------------------------

Userid=/

Buffer=10240000

Full=Y

-----------------------------------------------cut ------- ------------------------