本文共 1933 字,大约阅读时间需要 6 分钟。
Rman定时全备份脚本
1、定时备份任务
DB1-> crontab -l
30 22 * * * /rmanbackup/scripts/rmanbackup.sh
2、脚本内容
DB1-> more /rmanbackup/scripts/rmanbackup.sh
#/bin/bash
#export ...
export ORACLE_BASE=/oracle/db
export ORACLE_HOME=$ORACLE_BASE/product/db1
export ORA_GRID_HOME=/oracle/crs
export ORACLE_OWNER=oracle
export ORACLE_SID=gzdb1
export ORACLE_UNQNAME=gzdb
export PATH=$PATH:$ORACLE_HOME/bin:/sbin:/usr/sbin:/bin:/usr/local/bin:.
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export NLS_LANG=american_america.ZHS16GBK
export ORACLE_PATH=/home/oracle
today=`date +%Y%m%d`
find /rmanbackup/dbbak/ -name "*full*" -mtime +7 -exec rm {} \;
find /rmanbackup/dbbak/ -name "*archivelog*" -mtime +7 -exec rm {} \;
find /rmanbackup/dbbak/ -name "controlfile*" -mtime +7 -exec rm {} \;
find /rmanbackup/dbbak/ -name "spfile*" -mtime +7 -exec rm {} \;
rman target / nocatalog log /rmanbackup/rmanlog/rmanbk_$today.log append <
run {
crosscheck archivelog all;
delete noprompt expired archivelog all;
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup format '/rmanbackup/dbbak/gzdb_full_%T_%d_%s_%p_%u.dbf' database plus archivelog;
sql "ALTER SYSTEM switch logfile";
sql "ALTER SYSTEM switch logfile";
sql "ALTER SYSTEM switch logfile";
sql "ALTER SYSTEM switch logfile";
sql "ALTER SYSTEM switch logfile";
sql "ALTER SYSTEM switch logfile";
delete noprompt archivelog until time 'sysdate-7';
backup current controlfile format '/rmanbackup/dbbak/controlfile_%T_%U_%t.crl';
backup spfile format '/rmanbackup/dbbak/spfile_%T_%U_%t.ora';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
exit
EOF
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27571661/viewspace-1781718/,如需转载,请注明出处,否则将追究法律责任。