Saturday, August 23, 2014

expdp full database export / Shell Script

expdp_full_db.ksh

NOTE : change DP1, ORACLE_HOME, DIRECTORY, MAIL and  adjust days before removing dump

#!/bin/ksh
export ORACLE_SID=$1
export ORACLE_HOME=/ora01/oracle/product/11.2.0.4/db
export PATH=$ORACLE_HOME/bin:$PATH
export EXPDATE=`date "+%m%d_%H%M"`
export DP1=/oramisc01/oracle/export/${ORACLE_SID}

$ORACLE_HOME/bin/expdp \'/ as sysdba\'  job_name=job1 directory=dpdump dumpfile=expdp_$ORACLE_SID}_full_${EXPDATE}.dmp full=y flashback_time=\"TO_TIMESTAMP\(TO_CHAR\(SYSDATE,\'YYYY-MM-DD HH24:MI:SS\'\),\'YYYY-MM-DD HH24:MI:SS\'\)\" logfile=expdp_{ORACLE_SID}_full_${EXPDATE}.log statistics=none COMPRESSION=ALL

CLUSTER=N  filesize=20000000000 parallel=1

/bin/gzip ${DP1}/expdp_$ORACLE_SID}_full_${EXPDATE}.dmp


find ${DP1} -name exp_$ORACLE_SID}\* -mtime +7 -exec rm {} \;


tail -15 ${DP1}/expdp_$ORACLE_SID}_full_${EXPDATE}.log | mailx -s "$ORACLE_SID} database export output" abx@gmail.com