RMAN Recovery Methods: Restoring and Recovering All Datafiles
RMAN Recovery Methods: Restoring and Recovering All Datafiles
When performing a restore operation, it is best to open two telnet sessions, one for SQL commands, and one for
RMAN commands. For the rest of this document, RMAN commands will be prefaced with the RMAN> prompt,
and SQL commands will be prefaced with the SQL> prompt. A $ indicates that the command is executed from
the Unix prompt.
In this scenario, it is assumed that your control files are still accessible. You have a backup, done for example with
backup database plus archivelog;
Your first step is to make sure that the target database is shut down:
$ sqlplus “/ as SYSDBA”
SQL> shutdown abort;
ORACLE instance shut down.
Next, you need to start up your target database in mount mode. RMAN cannot restore datafiles unless the database is at
least in mount mode, because RMAN needs to be able to access the control file to determine which backup sets are
necessary to recover the database. If the control file isn't available, you have to recover it first. Issue the STARTUP
MOUNT command shown in the following example to mount the database:
Database mounted.
Since backup set files are created in an RMAN-specific format, you must use RMAN to restore the datafiles. To use
RMAN, connect to the target database:
The remainder of this example shows how to restore all of the datafiles of the target database. When the restore
command is executed, RMAN will automatically go to its last good backup set and restore the datafiles to the
state they were in when that backup set was created.
When restoring database files, RMAN reads the datafile header and makes the determination as to whether the file needs
to be restored. The recovery is done by allocating a channel for I/O and then issuing the RMAN restore database
command.
With Oracle9i and above, you don't need to allocate a channel explicitly. Instead, you can use the default channel mode:
For Oracle8i, the ALLOCATE, RESTORE, and RECOVER commands need to be enclosed by the run{} command:
RMAN> run {
allocate channel d1 type disk;
restore database;
recover database;
}
alter database open;
Once the recovery has been completed, execute a complete RMAN backup to establish a new
baseline.
Restoring Specific Tablespaces
In this scenario, it is assumed that your control files are still accessible. You have a backup, done for example with
backup database plus archivelog;
Take the tablespace that needs recovery offline, restore the tablespace, recover the tablespace, and bring the tablespace
online. If you cannot take the tablespace offline, then shutdown abort the database and restore in mount mode.
$ sqlplus “/ as SYSDBA”
SQL> shutdown abort;
SQL> startup mount;
$ rman target / rcvcat rcvcat/rcvcat@oemprod
RMAN> restore tablespace tab;
RMAN> recover tablespace tab;
SQL> alter database open;
Once the recovery has been completed, execute a complete RMAN backup to establish a new
baseline.
In this scenario, it is assumed that your control files are still accessible. You have a backup, done for example with
backup database plus archivelog;
Take the datafile that needs recovery offline, restore the datafile, recover the datafile, and bring the datafile online. If you
cannot take the datafile offline, then shutdown abort the database and restore in mount mode.
Once the recovery has been completed, execute a complete RMAN backup to establish a new
baseline.
In this scenario, it is assumed that your control files are backed up. You have a backup, done for example with backup
database plus archivelog;
In an ideal world you'll never use RMAN to restore a control file. But if something catastrophic happens, and you lose all
control files, here are the steps for getting them back:
The following examples assume that you are using a catalog. First, here's the simplest Oracle9i syntax for restoring a
control file:
$ sqlplus “/ as SYSDBA”
SQL> shutdown abort;
SQL> startup nomount;
$ rman target / rcvcat rcvcat/rcvcat@oemprod
Set the database id (DBID) with the following command. This is a 10-digit number that
RMAN uses to uniquely identify this database in the recovery log. The number can be
obtained from any previous RMAN backup log file.
Note, that all offline archivelogs are now useless, perform a full back as soon as possible.
Restoring Online Redologs
In this scenario, it is assumed that your control files are backed up. You have a backup, done for example with backup
database plus archivelog;
Set the database id (DBID) with the following command. This is a 10-digit number that
RMAN uses to uniquely identify this database in the recovery log. The number can be
obtained from any previous RMAN backup log file.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 09/28/2004 11:03:23
RMAN-06054: media recovery requesting unknown log: thread 1 seq 1 lowscn 8448414
Since the online logs were lost, complete recovery is not possible. Open the database with resetlogs to continue.
-------------------------------------IMPORTANT-------------------------------------------
During this type of recovery, if you receive error messages like this:
----------------------------------------------------------------------------------------
Incomplete recovery uses a backup to produce a non-current version of the database. In other words, you
do not apply all of the redo records generated after the most recent backup.
You usually perform incomplete recovery of the whole database in the following situations:
To perform incomplete media recovery, you must restore all datafiles from backups created prior to the time to which you
want to recover and then open the database with the RESETLOGS option when recovery completes. The RESETLOGS
operation creates a new incarnation of the database; in other words, a database with a new stream of log sequence
numbers starting with log sequence 1.
NOTE – Start every RMAN incomplete recovery with the following commands:
Once the recovery has been completed, execute the following steps:
• Delete prior backups with this command (from the RMAN prompt):
This command removes all prior backups from the RMAN catalog as they can no longer be used once the
database has been restarted with the resletlogs option. After completing this command, create a new RMAN
backup to establish a new baseline.
In the event that you want to recover the database archived redo logs until a desired time, you can use the following
commands:
or