Skip to content
Home » Oracle Database » How to Backup RMAN Configuration Daily

How to Backup RMAN Configuration Daily

Backup RMAN Configuration

RMAN can backup almost everything at any state of execution time, includes data, archive logs, even control file and spfile, but I see nothing about the configuration of itself.

For saving the current configuration of RMAN for re-creating the configuration on the same or different database in the future. Here I introduce an approach which combines shell scripting, crontab scheduling and RMAN CLI to achieve the goal.

A. Create a executable script file for execute RMAN.

[oracle@test ~]$ vi save_rman_config.sh
#!/bin/bash
. ~/.bash_profile
rman target / << EOF | grep ^CONFIGURE > ~/rman_config_`date +"%Y%m%d"`.rman
  show all;
  exit;
EOF

Please note that I keep only the lines that start with CONFIGURE to make the all output executable for RMAN CLI and logged in a daily file.

B. Add executable permission on the file.

[oracle@test ~]$ chmod u+x save_rman_config.sh

C. Add the job to the crontab for executing daily.

[oracle@test ~]$ crontab -e
* 4 * * * /home/oracle/save_rman_config.sh
[oracle@test ~]$ crontab -l
* 4 * * * /home/oracle/save_rman_config.sh

D. Check the result

[oracle@test ~]$ ll
...
-rw-rw-r-- 1 oracle oracle      1421 Oct 27 18:14 rman_config_20151027.rman
...
[oracle@test ~]$ cat rman_config_20151027.rman
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO '%F'; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE ON;
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'basic' AS OF RELEASE 'default' OPTIMIZE FOR LOAD TRUE;
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/12.1.0/dbhome_1/dbs/snapcf_orcl.f'; # default

The really best thing is that the neat *.rman file only contains executable configuring commands for RMAN, which can be directly used by other shell scripts or by DBA.

If you don't like to schedule another RMAN job, you may also add SHOW ALL into your daily backup script. Just remember to set RMAN log location and then check them regularly.

Further reading: How to Reset RMAN Configuration

Leave a Reply

Your email address will not be published. Required fields are marked *