Berikut ini Script sederhana untuk membuat logical backup dimana file backup akan langsung di zip dan backup file yang lebih dari dua hari akan di delete . Mudah-mudahan bermanfaat :)
[root@cl01nodsq endera_scripts]# cat expdb.sh
#!/bin/ksh
#
# Author : Ida Bagus Enderajana
# Website: http://cortex165.blogspot.com/
#
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
# Create Directory for dmp files
EXPDIR=/u01/backup_data/${TODAY}
#RETENTION=25
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 the file backup
gzip $FILE_NAME
find /u01/backup_data/ -ctime 2 -name '2012*' | xargs /bin/rm -rf
No comments:
Post a Comment