Thursday, June 3, 2010

RMAN backup script

In Windows 2003, I created following 4 scripts to do RMAN Incremental level 0 and Incremental level 1 backups:
Incremental Level 0 Backup
Script #1 - Incremental level 0

set ORACLE_SID=msrbrtrs
rman target / nocatalog cmdfile=S:\rman_bk\rtrs\level_0.rman log=S:\rman_bk\rtrs\rman_level_0_%date:~-4,4%%date:~-7,2%%date:~-10,2%-%time:~-11,2%%time:~-8,2%%time:~-5,2%.log.log




Script #2: the above script calls cmd file 

#1 - list current backups
list backup;


#2 - check backup status to see backup files are obsolete (exceed retention window) or expired (removed without using RMAN)
crosscheck backup;


#3 - delete expired backup
#delete expired backup;


#4 - delete obsolete backup files, which exceed the retention window.
delete obsolete;


#5 - check physical file corruption before RMAN backup
#backup validate database archivelog all;


#6 - check logical corruption before RMAN backup
#backup validate check logical database archivelog all;


#7 - backup database plus all archive log files.  After backup, delete all archived log files
backup incremental level 0 database plus archivelog all delete input;


#8 - verify the availability and integrity of backup pieces required by RMAN to perform the restore operations. 
#By default, RMAN checks only for physical corruption when validating.
restore database validate;
restore archivelog all validate;


#By default, RMAN checks only for physical corruption when validating.  Use command below to check logical corruption:
restore database validate check logical;




#Exit
exit;


Incremental Level 1 Backup
Script#3 - Incremental level 1

set ORACLE_SID=msrbrtrs
rman target / nocatalog cmdfile=S:\rman_bk\rtrs\level_1.rman log=S:\rman_bk\rtrs\rman_level_1_%date:~-4,4%%date:~-7,2%%date:~-10,2%-%time:~-11,2%%time:~-8,2%%time:~-5,2%.log.log


Script #4 - cmd file for level 1 backup


#1 - list current backups
list backup;


#2 - check backup status to see backup files are obsolete (exceed retention window) or expired (removed without using RMAN)
crosscheck backup;


#3 - delete expired backup
#delete expired backup;


#4 - delete obsolete backup files, which exceed the retention window.
delete obsolete;


#5 - check physical file corruption before RMAN backup
#backup validate database archivelog all;


#6 - check logical corruption before RMAN backup
#backup validate check logical database archivelog all;


#7 - backup database plus all archive log files.  After backup, delete all archived log files
backup incremental level 1 cumulative database plus archivelog all delete input;


#8 - verify the availability and integrity of backup pieces required by RMAN to perform the restore operations. 
#By default, RMAN checks only for physical corruption when validating.
restore database validate;
restore archivelog all validate;


#By default, RMAN checks only for physical corruption when validating.  Use command below to check logical corruption:
restore database validate check logical;




#Exit
exit;





0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home