Skip to content
Home » Oracle Database » How to Restore Controlfile

How to Restore Controlfile

When the controlfile is missing, the database can't mount the controlfile, you need to restore the controlfile before going further. But first of all, you must have at least one copy of the controlfile before restoring it. Otherwise, you will have a big trouble.

The best practice of the backup strategy against the controlfile is to configure controlfile AUTOBACKUP ON, and furthermore, backup the controlfile as a copy regularly in case the failure of the autobackup.

Restore Control File

There're several ways to solve the problem.

From AUTOBACKUP

RMAN will pick the latest autobackup to restore control file.

[oracle@primary01 ~]$ rman target /
...
connected to target database: COMPDB (not mounted)

RMAN> run {
2> set dbid 841830157;
3> set controlfile autobackup format for device type disk to '+data/primdb/autobackup/%F';
4> restore controlfile from autobackup;
5> }

executing command: SET DBID

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

Starting restore at 12-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 instance=primdb1 device type=DISK

recovery area destination: +DATA
database name (or database unique name) used for search: PRIMDB
channel ORA_DISK_1: AUTOBACKUP +data/PRIMDB/AUTOBACKUP/2012_12_12/s_801851388.1110.801851393 found in the recovery area
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20121212
channel ORA_DISK_1: restoring control file from AUTOBACKUP +data/PRIMDB/AUTOBACKUP/2012_12_12/s_801851388.1110.801851393
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=+DATA/primdb/controlfile/current.260.801867061
Finished restore at 12-DEC-12

To know how to enable AUTOBACKUP, we have some steps.

From a Copy

RMAN> restore controlfile from '/tmp/primdb-20121212.ctl';

Starting restore at 12-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 instance=primdb1 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=+DATA/compdb/controlfile/current.260.761506189
Finished restore at 12-DEC-12

From a Backup Piece

If the backup set contains control file, you can use one of the backup pieces to restore control file.

RMAN> restore controlfile from '/tmp/rman/backup_0atgl7q2_1_1';

Of course, you can put all the commands together in a run block like this:

run {
set dbid 841830157;
set controlfile autobackup format for device type disk to '%F';
restore controlfile from autobackup;
alter database mount;
recover database;
alter database open resetlogs;
}

More related posts that you may be interested in:

Leave a Reply

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