This article is not yet completed and verified, so caution is advised on its contents.
CMD (or BAT) file for full backup
rem rem rmanFULL.cmd rem rem %1% is the ORACLE_SID rem set NLS_DATE_FORMAT=YYYY-MM-DD-HH24:MI:SS set NLS_LANG=AMERICAN_AMERICA set ORACLE_SID=%1% set BACKUP_DIR=E:\BACKUP rem rem Do the backup and save the result status from RMAN rem rman cmdfile=rmanFULL.rcv log=rmanFULL_%ORACLE_SID%.log set RMANRC=%ERRORLEVEL% sqlplus monitor/******** @rman_report %RMANRC% FULL <Customer> rem rem Delete any files older than the retention period rem if %RMANRC% NEQ 0 goto exitlabel forfiles /p %BACKUP_DIR%\%ORACLE_SID% /m *.DMP /d -1 /c "cmd /c del @path" :exitlabel
CMD (or BAT) file for archive backup
rem rem rmanARCH.cmd rem rem %1% is the ORACLE_SID rem set NLS_DATE_FORMAT=YYYY-MM-DD-HH24:MI:SS set NLS_LANG=AMERICAN_AMERICA set ORACLE_SID=%1% set BACKUP_DIR=E:\BACKUP rem rem Do the backup and save the result status from RMAN rem rman cmdfile=rmanARCH.rcv log=rmanARCH_%ORACLE_SID%.log set RMANRC=%ERRORLEVEL% sqlplus monitor/******** @rman_report %RMANRC% ARCH <Customer>
RMAN command file for full backup
RMAN command file for archive backup
# # rmanARCH.rcv # connect target / run { configure retention policy to redundancy 1; configure controlfile autobackup off; # # Backup the control file and spfile to create a valid restore point # allocate channel d1 type disk maxpiecesize 2G; backup as compressed backupset incremental level 0 format 'E:\Backup\%d\%T-CTRL-%s-%p.dmp' current controlfile spfile skip inaccessible skip readonly; release channel d1; # # Backup all the existing archive log files # allocate channel d1 type disk maxpiecesize 2G; sql 'alter system archive log current'; backup as compressed backupset format 'E:\Backup\%d\%T-ARCH-%s-%p.dmp' skip inaccessible archivelog all delete all input; release channel d1; } # # Report and delete any obsolete backupsets # report obsolete; delete force noprompt obsolete; # # Crosscheck the backup files for existence # allocate channel for maintenance type disk; crosscheck backup; release channel; # # Delete entries for non-existing backupset to remove the clutter # allocate channel for delete type disk; delete force noprompt expired backup; release channel;