Backup Recovery   «Prev  Next»
Lesson 9Perform tablespace recovery with line command RMAN
ObjectiveUse RMAN to restore tablespace, control file, and archived log files.

Perform Tablespace Recovery

To restore Tablespace to its present location


Start RMAN and connect to the target database and recovery catalog database. For example, enter:
% RMAN CATALOG RMAN/RMAN@BACKUP
RMAN> CONNECT TARGET RMAN/RMAN@PETS

After allocating the channels, take the tablespace that you want to recover offline and restore the tablespace.
For example, to restore tablespace TEMP to the disk you might issue:
RUN{
SQL 'ALTER TABLESPACE TEMP OFFLINE TEMPORARY';
ALLOCATE CHANNEL C1 TYPE DISK;
RESTORE TABLESPACE TEMP;
}

Once the database is restored, open the database.

To restore the control file to its present location by using a recovery catalog


Start RMAN and connect to the target and recovery catalog databases. For example, enter:
% RMAN CATALOG RMAN/RMAN@BACKUP
RMAN> CONNECT TARGET RMAN/RMAN@PETS

Start the instance without mounting the database:
STARTUP NOMOUNT;

If for some reason you need to restore a control file created before a certain date, issue a SET UNTIL command for that date. Otherwise, allocate one or more channels, restore the control file, mount, and open the database.
RUN
{
ALLOCATE CHANNEL C1 TYPE DISK;
RESTORE CONTROLFILE;
ALTER DATABASE MOUNT;
}

RMAN automatically replicates the control file to the locations specified by the CONTROL_FILES initialization parameter.

To restore archived log files

Start RMAN and connect to the target database and catalog database. For example, enter:

% RMAN CATALOG RMAN/RMAN@BACKUP
RMAN> CONNECT TARGET RMAN/RMAN@PETS

If the database is open, shut it down, and mount it.
SHUTDOWN IMMEDIATE; STARTUP MOUNT
If desired, specify the new location for the restored archived logs by using
SET ARCHIVELOG DESTINATION
. Otherwise, allocate the channels and restore the archived redo logs.
For example, this script restores all backed up archivelog files:

RUN
{
SET ARCHIVELOG DESTINATION 
TO '/ORACLE/TEMP_RESTORE';
ALLOCATE CHANNEL CH1 TYPE DISK;
RESTORE ARCHIVELOG ALL;
}

To avoid performing media recovery on a tablespace that cannot be opened because the database was shut down abruptly during a tablespace backup, issue the following command.
ALTER DATABASE DATAFILE <datafile name> 
END BACKUP;

This will bring the tablespaces out of the hot backup mode. You can now open the database.
If you must perform a media recovery, check if the database is mounted. If not, mount the database and issue the RECOVER command.
RECOVER DATABASE;

Once the database is recovered, open the database.
The next lesson uses the Recovery Manager to recover a failed database.

Perform tablespace- Exercise

Click the Exercise link below to practice using RMAN to restore a tablespace.
Perform Tablespace- Exercise