建立批处理文件:backupdb.bat
内容如下:
rem @ECHO OFF
set aFile=backuplog_%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%.log
set aDir=%~dp0
RMAN cmdfile '%aDir%BACKUPDB.RMAN' >> "%aDir%%aFile%"
exit
该批处理调用backupdb.rman命令文件
内容如下
connect target /
RUN{
backup database plus archivelog delete input;
crosscheck backup;
delete expired backup;
DELETE OBSOLETE RECOVERY WINDOW OF 2 DAYS;
}
quit
需要在rman中对channels和备份设备位置进行定义, 每天自动备份,备份保留2天,每天一个日志文件,并且备份时删除归档日志