Skip to content

How RMAN Backup Controlfile

  • by

Backup Controlfile

Since the controlfile is a very busy file on reading and writing when your database is open, you can't copy the file directly to another place. Instead, you should use SQL or RMAN to snapshot online controlfile out of the database. This will make the file consistent.

1. SQL Backup

You can use SQL statement to backup a copy of controlfile to a specific location.

SQL> alter database backup controlfile to '/tmp/primdb1-20181025.ctl';

Database altered.

SQL> !ls -l /tmp/primdb1-20121212-2.ctl
-rw-r----- 1 oracle asmadmin 19709952 Oct 25 16:24 /tmp/primdb1-20181025.ctl

2. RMAN Backup Copy

Use the following statement to get a copy of current controlfile.

RMAN> backup as copy current controlfile format '/tmp/primdb1-20121212.ctl';

Starting backup at 12-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=98 instance=primdb1 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/tmp/primdb1-20121212.ctl tag=TAG20121212T162940 RECID=16 STAMP=801851384
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 12-DEC-12

Starting Control File and SPFILE Autobackup at 12-DEC-12
piece handle=+DATA/primdb/autobackup/2012_12_12/s_801851388.1110.801851393 comment=NONE
Finished Control File and SPFILE Autobackup at 12-DEC-12

Please note that, the above copies can be used directly. No need to restore before using it, just copy it to the destination specified in SPFILE.

Above copies of the current controlfile will be regarded as BACKUP controlfiles, not CURRENT if we use them to recover databases.

3. RMAN Backup Piece

We can also backup the controlfile as a backup piece.

RMAN> backup current controlfile format '/backup/control-%U';

Starting backup at 29-NOV-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 29-NOV-18
channel ORA_DISK_1: finished piece 1 at 29-NOV-18
piece handle=/backup/control-030fds04_1_1 tag=TAG20181129T205844 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-NOV-18

SPFILE

In practice, we backup SPFILE as well as the controlfile in the same backup piece.

RMAN> backup spfile include current controlfile format '/backup/control-%U';

Starting backup at 29-NOV-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1730 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 29-NOV-18
channel ORA_DISK_1: finished piece 1 at 29-NOV-18
piece handle=/backup/control-050fe07q_1_1 tag=TAG20181129T221106 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-NOV-18

Let's see the result.

[oracle@test ~]$ ll /backup
total 43680
-rw-r----- 1 oracle oinstall 22347776 Nov 29 20:58 control-030fds04_1_1
-rw-r----- 1 oracle oinstall 22380544 Nov 29 22:11 control-050fe07q_1_1

The backup piece of controlfile containing SPFILE is a little bigger than the other.

4. RMAN AUTOBACKUP

Setting AUTOBACKUP ON in RMAN will enable the database to backup the controlfile to specific path automatically whenever the definition of database is changed.

If there's anything wrong, you can restore controlfile by those backups.

Leave a Reply

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