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:
-
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 duringBACKUP ARCHIVELOG ALL
command?
And why this different size? If they are both controlfile backup I expect they have the same size. -
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 supposeCOPY LEVEL 0
command overwrite without any warning, is it right?
Best Answer
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.
DELETE NOPROMPT BACKUP OF ARCHIVELOG UNTIL TIME='sysdate-6'
deletes archivelog backups older than 6 days.