Oracle 11g EXPDP、RMAN自動備份SHELL指令碼

feelpurple發表於2016-06-23
#!/bin/sh
umask 022
set -o vi

export ORACLE_SID=market
export ORACLE_BASE=/app/usr/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11gr2
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/local/lib
export PATH=$PATH:$ORACLE_HOME/bin:$PATH
export LANG=en_US.UTF-8
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
#EXPDP
find /app/usr/oracle/bk -ctime +3 -print | xargs rm;
now=`date +%Y%m%d`
expdp system/System#2013 directory=bk schemas=market dumpfile=market_$now.dmp logfile=expdp_$now.log
#RMAN
rman target / log=/home/oracle/log/rman_$now.log << EOF
run {
configure retention policy to recovery window of 2 days;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/app/usr/oracle/bk/cf_%F';
allocate channel C1 device type disk format '/app/usr/oracle/bk/rman_%U';
backup as compressed backupset database skip inaccessible
plus archivelog filesperset 20
delete all input;
release channel C1;
}

allocate channel for maintenance device type disk;
crosscheck backupset;
delete noprompt obsolete;
DELETE EXPIRED BACKUP;
exit
EOF

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

相關文章