In general there are three steps involved in restoring files :
1) Ensure that the target database is started in the appropriate mode for the restoration operation ====>
a) For lost control files, this will be nomount mode.
b) If the entire database needs to be restored, this will be mount mode
c) If datafiles that don't belong to the SYSTEM tablespace are damaged, you have the option of keeping the database open and taking
only the tablespace(s)/datafile(s) that needs to be restored offline.
2) Start RMAN and connect to the target and recovery catalog if one is being used
3) Run the appropriate RMAN RESTORE command to bring back required files. The requested files and the appropriate archived redo log files will be restored.
Once the necessary files are restored, you need to recover your database and open it for use.
Restore and Recovery Scenarios :
Scenario 1) Restoring and Recovering All Datafiles
=========================================
In this scenario, it is assumed that your control files are still accessible.
step 1) Make sure that the target database is shut down.
step 2) Start up your target database 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.)
step 3) rman connect to target and catalog database and run below commands in series
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open;
RMAN will go to its last good backup set and restore the datafiles to the state they were in when that backup set was created.
With Oracle9i & above, you don't need to allocate a channel explicitly. Instead, you can use the default channel mode
Or alternatively, once RMAN has restored the datafiles, you can use SQL*Plus to recover the database and open it for use:
$ sqlplus /nolog
SQL> connect sys/hinghoda as SYSDBA;
SQL> recover database;
SQL> alter database open;
Scenario 2) Restoring Specific Tablespaces/Datafiles
============================================
> a very straightforward task
> you must first take the tablespace or datafile offline
For tablespace :
RMAN> sql 'alter tablespace users offline';
RMAN> restore tablespace users;
RMAN> recover tablespace users;
For datafile :
RMAN> sql 'alter database datafile '/d0101/oradata/brdstn/users_01.dbf' offline;
RMAN> restore datafile '/d0101/oradata/brdstn/users_01.dbf';
RMAN> recover datafile '/d0101/oradata/brdstn/users_01.dbf';
Scenario 3) Restoring Read-Only Tablespaces
=======================================
> Once you back up a read-only tablespace, you don't need to back it up again. However, you may want to periodically back up your read-only tablespaces so that in the event of a recovery, RMAN doesn't have to retrieve a backup set that may be on tape and offsite.
> RMAN does not require any archived redo log files to restore and recover a read-only tablespace
> To recover a read-only tablespace you do not need to bring down the database.
Steps :
RMAN> sql 'alter tablespace old_rnd offline';
RMAN> restore tablespace old_rnd;
RMAN> sql 'alter tablespace old_rnd online';
Scenario 4) Point-in-Time Recovery
==============================
> If your database is in archivelog mode, you can do point-in-time recovery
IMPORTANT
Point-in-Time Recovery is performed against the entire database and not against a single datafile or tablespace.
Steps for cancel-based recovery :
Here use RMAN to restore the datafiles and then uses SQL*Plus to perform a cancel-based recovery
RMAN> restore database;
SQL> recover database until cancel;
Once you have recovered your database to the appropriate point, you can open it for use. Since you are doing a point-in-time recovery, you need to open the database with the resetlogs parameter:
SQL> alter database open resetlogs;
Since the logs were reset, it is crucial that an immediate backup be taken of the database.
Scenario 5) Restoring Control Files
==============================
> Start up your database in nomount mode first.
RMAN> startup nomount;
RMAN> restore controlfile;
Scenario 6) Restoring Archived Redo Log Files
=======================================
> When you issue a RECOVER command from RMAN, the RMAN utility first looks on disk to see if the necessary archived redo log files are present. If they aren't, RMAN retrieves them from any RMAN archived redo log file backups that you've taken. If you want to explicitly tell RMAN to bring back your archived redo log files, you use the RESTORE ARCHIVELOG command.
> For datafile recovery, if there is an incremental backup available, RMAN uses an incremental backup over an archived redo log file.
Command to use :
RMAN> run
{
2> set archivelog destination to '/d00/backup/';
3> restore archivelog all;
}