Script dibawah ini digunakan untuk membackup schema database
#!/bin/ksh
#
#
# Author : Ida Bagus Enderajana
#
#
TODAY=$(date +%Y\%m\%d)
export HOST=`hostname`
export PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/u01/app/oracle/product/10.2.0/db_1/bin:/bin:/usr/sbin:/sbin:/usr/bin:/usr/ccs/bin:/usr/ucb:/usr/X11R6/lib
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
# Buat Directory untuk dmp files
EXPDIR=/u01/backup_data/${TODAY}
if [ ! -d $EXPDIR ]
then
mkdir -p $EXPDIR
fi
# Create option for export
while getopts :s:u:r:f: opt;
do
case $opt in
s) ORACLE_SID=$OPTARG ;;
u) OWNERS=$OPTARG ;;
r) ROW=$OPTARG ;;
f) NFILE=$OPTARG ;;
\?) usage ;;
esac
done
FILE_NAME=$EXPDIR/bkp_"$NFILE"_$TODAY.dmp
#
#
exp userid=system/manager@$ORACLE_SID rows=$ROW owner=$OWNERS file=$EXPDIR/bkp_"$NFILE"_$TODAY.dmp log=$EXPDIR/bkp_"$NFILE"_$TODAY.log feedback=10000 buffer=10000000 consistent=y direct=y statistics=none
#
# Zip file backup
gzip $FILE_NAME
find /u01/backup_data/ -ctime 2 -name '2012*' | xargs /bin/rm -f
No comments:
Post a Comment