http://www.sagacityhr.com/forum/showtopic-155.html
创建 backup_arclog.rcv 文件,文件内容为:
connect target sys/sys@hrdbw
run {
backup archivelog all delete all input; #将archivelog 转化为 backupset 并删除
delete noprompt backupset completed before 'sysdate-2'; #删除两天前的backupset
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
调用的shell语句如下
rman cmdfile='$Path/backup_arclog.rcv ' log='$Path/rman.log'
将该语句用crontab进行调度,可以每天生成一个 log文件
若要系统自动每天调用,则使用crontab来调度.sh文件,下面是backup.sh文件的内容:
export ORACLE_BASE
export ORACLE_HOME
export ORACLE_SID
export PATH
export LD_LIBRARY_PATH
#上面输出环境变量是因为该shell要在oracle账户下执行,这些环境变量是保证能够调度rman
dw=`date +%Y%m%d`
rman cmdfile=/usr/oracle/rman backup_arclog.rcv log=/us/oracle/rman/rman_$dw.log;
后一语句是为了每次生成一个当天的rman日志
-----
configure controlfile autobackup on;
backup database skip inaccessible
plus archivelog delete all input;
delete noprompt archivelog all completed before 'sysdate -3';
-----
configure retention policy to recovery window of 7 days;
configure controlfile autobackup format for device type disk to 'E:\oracle\backup\%F';
configure channel device type disk format '/tmp/%U';
delete noprompt archivelog until time "to_date(to_char(sysdate-3,'yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss')";
release channel ch1;
allocate channel for maintenance device type disk;
crosscheck backupset;
delete noprompt obsolete;
No comments:
Post a Comment