ORACLE dump ksh

oo0yuki0oo發表於2011-07-06

$ more exp_full_db.ksh
#!/usr/bin/ksh
HostName='hostname'
LogName='whoami'
EnvFlag='echo $LogName|cut -c1-1'
OsName='uname'


case $OsName in
AIX ) echo $OsName ...
GET_ACL="aclget"
MAIL="mailx"
ZIP="/usr/bin/gzip"
LogName='/usr/bin/whoami'
export LogName
;;
HP-UX ) echo $OsName ...
GET_ACL="getacl"
MAIL="mailx -m"
ZIP="/usr/contrib/bin/gzip"
LogName='/usr/bin/whoami'
export LogName
;;
SunOS ) echo $OsName ...
LogName='/usr/ucb/whoami'
ZIP="/usr/bin/gzip"
MAIL="mailx"
export LogName
GET_ACL="getfacl"
;;
Linux ) echo $OsName ...
LogName='/usr/bin/whoami'
MAIL="mailx"
ZIP="gzip"
export LogName
GET_ACL="getfacl"
;;
esac

Cnt=`echo $#`
if [ $Cnt -ne 3 ]
then
echo "Usage : exp_full_db.ksh "
echo " e.g. exp_full_db.ksh testdb /optware/oracle/10.2/db /optware/oracle/exportdmp"
exit 0
fi
dbname=$1
ORACLE_HOME=$2
EXPDIR=$3
export ORACLE_HOME
ORACLE_SID=$dbname
export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH
export PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export LD_LIBRARY_PATH

if [ ! -d ${ORACLE_HOME} ]
then
echo "ORACLE_HOME ${ORACLE_HOME} does not exist "
exit 0
fi

if [ ! -d ${EXPDIR} ]
then
echo "EXPDIR ${EXPDIR} does not exist "
exit 0
fi

if [ ! -d ${EXPDIR}/log ]
then
mkdir -p ${EXPDIR}/log
fi

dd=`date +%d`
TODAY=`date +'%d-%m-%Y'`
time_to_delete='date +"%d%m%Y%H%M%S"'
LOG=${EXPDIR}/log/exp_full_db_${TODAY}.log

ORA_VER_CHK='11'

### echo exp file=${EXPDIR}/exp_db_${ORACLE_SID}_$dd.dmp log=${EXPDIR}/log/exp_db_${ORACLE_SID}_$dd.log buffer=512000 compres
s=y rows=y statistics=none
echo "/ as sysdba" |exp file=${EXPDIR}/exp_db_${ORACLE_SID}_$dd.dmp log=${EXPDIR}/log/exp_db_${ORACLE_SID}_$dd.log buffer=512
000 compress=y rows=y statistics=none


if [ `grep EXP- ${EXPDIR}/log/exp_db_${ORACLE_SID}_$dd.log | wc -l ` -eq 0 ]
then

echo "Export DB$ table is successful... " >> $LOG


else
echo "Export DB is failed..." >> $LOG
fi

$

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8337095/viewspace-1052058/,如需轉載,請註明出處,否則將追究法律責任。

相關文章