Rman controlfile and rotation

backuporacle-10grman

I got an Oracle 10g server with a bash script running every night which extract each datafile and create an rman script, which is launched from the bash script itself and make backups.

CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/oracle/archivelogs/autobackup_control_file%F';
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
CROSSCHECK ARCHIVELOG ALL;
CROSSCHECK BACKUP;
ALLOCATE CHANNEL RMAN_BACK_CH01 TYPE DISK;
COPY LEVEL 0
  DATAFILE 1 TO '/opt/oracle/backup/datafile1.dbf'
, DATAFILE 2 TO '/opt/oracle/backup/datafile2.dbf'
...
, DATAFILE N TO '/opt/oracle/backup/datafileN.dbf'
;
SQL 'alter system archive log current';
BACKUP FORMAT '/opt/oracle/archivelogs/archive_logs_%d_%s-%t.bck' ARCHIVELOG ALL DELETE INPUT;
BACKUP CURRENT CONTROLFILE FORMAT '/opt/oracle/archivelogs/controlfile_%d_%s-%t.bck';
RELEASE CHANNEL RMAN_BACK_CH01;
}
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT BACKUP OF ARCHIVELOG UNTIL TIME='sysdate-6';

As you can see from the script the backups are made via datafile copy and archivelogs backup.
I got two questions:

  1. on the archivelogs directory the script creates two controlfile backups (autobackup_control_filec-* and controlfile_SID_) which have quite the same size (6.1MB vs 6.2MB) but not exactly the same.
    controlfile_SID_
    file creation is clear from the syntax, but when the autobackup_control_filec-* is created? Perhaps during BACKUP ARCHIVELOG ALL command?
    And why this different size? If they are both controlfile backup I expect they have the same size.

  2. Datafile backup rotation seems to work fine, every day I found in /opt/oracle/backup only the backup files from the latest backup schedule, but in logs I don't find any trace of old backup deletion or messages on overwrite.
    I suppose COPY LEVEL 0 command overwrite without any warning, is it right?

Best Answer

  1. http://docs.oracle.com/cd/B19306_01/backup.102/b14191/rcmconc1.htm#BRADV111

If CONFIGURE CONTROLFILE AUTOBACKUP is ON, then RMAN automatically backs up the control file and the current server parameter file (if used to start up the database) in one of two circumstances: when a successful backup must be recorded in the RMAN repository, and when a structural change to the database affects the contents of the control file which therefore must be backed up.

This means that the control file is backed up in the following situations:

  • After every BACKUP command issued at the RMAN prompt.
  • At the end of a RUN block, if the last command in the block was BACKUP.
  • Whenever a BACKUP command within a RUN block is followed by a command that is not BACKUP.

In your case, the backup is created before RELEASE CHANNEL. The autobackup would happen after COPY, BACKUP ... ARCHIVELOG and BACKUP ... CONTROLFILE, but since these are in the same RUN block, why perform the work of creating the autobackup 3 times unnecessarily, when it is enough to perform the autobackup after the last BACKUP command?

The size is different because the autobackup contains the SPFILE also.

The autobackup finishes after the controlfile backup, so the autobackup contains the entry pointing to the previous controlfile backup, but the previous controlfile backup doesn't know about the autobackup, that is another difference between them.

When the controlfile grows, it gets more space allocated than it immediately needs, leaving some empty space in it that can be used later. Because of this, the controlfile and the controlfile autobackup can be the same size (when no SPFILE in use), but their content will be still different. Outdated entries can also be reused in the controlfile to prevent the controlfile growing too big.

  1. COPY overwrites the copies of datafiles. DELETE NOPROMPT BACKUP OF ARCHIVELOG UNTIL TIME='sysdate-6' deletes archivelog backups older than 6 days.