Restore the control file and SPFILE with RMAN
Restore the control file from an RMAN autobackup, depending on the backup location and name.
This procedure restores the control file from an RMAN autobackup when the control files are lost. The example uses the instance name ORCL and a sample DBID. Replace them with your own values. You need the DBID of the database, which you can read from the RMAN banner or from the previous backup logs.
1. Set the environment
On Windows:
set ORACLE_SID=ORCL
echo %ORACLE_SID%
On AIX or Linux:
export ORACLE_SID=ORCL
echo $ORACLE_SID
2. Connect to RMAN
rman target / nocatalog
3. Set the DBID
RMAN> set DBID 1234567890
4. Start the instance in nomount
RMAN> startup nomount;
Then pick the variant that matches how the autobackup was made.
Autobackup with the default name (%F) in the default location (%ORACLE_HOME%\database on Windows, $ORACLE_HOME/dbs on Unix):
RMAN> restore controlfile from autobackup maxdays 10;
The default search window is 7 days. To restore to a point in time:
RMAN> restore controlfile from autobackup until time
"to_date('12/07/2005 13:05:05','MM/DD/YYYY HH24:MI:SS')";
Autobackup with a custom name in the default location:
RMAN> run {
set controlfile autobackup format for device type disk
to 'cfile_autobkp_orcl_%F.bkp';
restore controlfile from autobackup maxdays 10;
}
Autobackup with a custom name in a custom location:
RMAN> run {
set controlfile autobackup format for device type disk
to 'E:\RMAN_backups\cfile_autobkp_orcl_%F.bkp';
restore controlfile from autobackup maxdays 10;
}
The same can be written with an explicit channel:
RMAN> run {
set controlfile autobackup format for device type disk
to 'E:\RMAN_backups\cfile_autobkp_orcl_%F.bkp';
allocate channel c1 device type disk;
restore controlfile from autobackup maxdays 10;
}
Restore the control file to another location. The source notes that the database does not start from a control file outside the default location unless the parameter file points to it (control_files):
RMAN> run {
set controlfile autobackup format for device type disk
to 'E:\RMAN_backups\cfile_autobkp_orcl_%F.bkp';
restore controlfile to 'E:\restore\control01.ctl' from autobackup maxdays 10;
}
Restore the control file from a backup set (the backup piece name can differ when CONTROLFILE AUTOBACKUP is on):
RMAN> run {
restore controlfile from 'E:\RMAN_backups\BACKUP_ORCL_SET_220_PIECE_1_T_701624307';
}
5. Mount the database
alter database mount;
6. Recover the database
RMAN> recover database noredo; -- NOARCHIVELOG mode
RMAN> recover database; -- ARCHIVELOG mode
7. Open the database with RESETLOGS
alter database open resetlogs;
Notes
- If autobackup is off, the SPFILE cannot be restored this way. The source points to a separate article on restoring the SPFILE when autobackup is off: https://redikx.wordpress.com/2011/07/29/restore-spfile-when-autobackup-is-off/
- The control file restore procedure above comes from https://www.learn-it-with-examples.com/database/oracle/backup-recovery/restore-controlfile-using-oracle-rman.html