Oracle RMAN Backup Scripts

How to write a RMAN backup scripts and what are the points to be considered?

The point to be considered when writing a RMAN Backup Scripts are as follows:

1. After Each and Every Backup must read Backup log file carefully. 

2. Put  “Set Echo ON” at the beginning of RMAN script then RMAN will reflect all command in log files. 

3. Use “Show all” Command in RMAN script, it will allow you to understand behaviors of RMAN Backup. 

4. Use the command to find the Total execution time of script in the RMAN backup script that will help you to manage the expected time of next backup. 

5. Do not overwrite the Backup log files. The log file is good alternative solution of information in case the Rman Catalog is not available. Use the command to generate log file sequence or some alternative solution. 

6. Do not use Crosscheck command with RMAN backup script. By using it wrong place in your backup script will make recovery impossible. Handle it manually as required for precaution. 

7. Always Backup controlfile as the last step in your backup script. After that do not use Crosscheck or Obsolete command. 

8. Do not rely on one backup only. You should always have second option for potential recovery. Possibly keep one set of copy to another server. 

9. Use Connect Target with RMAN Backup script rather than passing it as an RMAN Executable Parameter. 

10. Use “resync catalog” command to synchronize the Catalog with the backup as a last step of the RMAN script. 

11. Do not rely on the RMAN stored configuration setting always put the configuration with the Backup script. 

12. Use “Report Need Backup” command to verify your backup up to the mark of recovery process. 

13. Use “Report unrecoverable” command with the backup script. This will indicate which database files need to be backed up to meet a configured or specified retention policy
 

Example of writing a RMAN backup scripts.

Backup a complete database: 

(If the target database is in archive mode, this can be done while the database is open)

RMAN> 

run { 

 # backup complete database to disk 

 allocate channel c1 type disk; 

 backup full                        

 tag full_db 

 format '/usr1/ora817/test/rman/db_d.dmp'

 (database); 

 release channel c1; 

 } 

You can create a script and use it multiple times, so each time you don't need to type the above script. Just make sure to drop the old backup files.

RMAN> 

create script full_db_backup { 

 allocate channel c1 type disk; 

 backup full database 

 format '/usr1/ora817/test/rman/db_%d.dmp';

 release channel c1; 

 } 

This is how you run the script:

RMAN> 

run { execute script full_backup ;} 

Archive logs too can be backed up along with the database in one script:

RMAN> 

create script full_db_arc_backup { 

 allocate channel c1 type disk; 

 backup full database 

 format '/usr1/ora817/test/rman/db_%d.dmp'; 

 release channel c1; 

 allocate channel c2 type disk format '/usr1/ora817/test/rman/arc_%d.dmp'; 

backup (archivelog all delete input); 

 release channel c2;        

 } 

- '%d' puts database name in the backup file name.

 - 'all delete input' in above script deletes all the archive logs once the backup is 

    complete, thus frees up the space.

RMAN> 

run { execute script full_db_arc_backup ;} 

Oracle Database

See Also
Steps To Rename a Database

Have a Oracle Question
Do you have an Oracle Question?

Oracle Books
Oracle Certification, Database Administration, SQL, Application, Programming Reference Books

Oracle Application
Oracle Application Hints and Tips

Oracle Home
Oracle Database, SQL, Application, Programming Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.