Skip Headers
Oracle® Database Backup and Recovery Quick Start Guide
10g Release 2 (10.2)

Part Number B14193-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

6 Restoring and Recovering Database Files

Use the RESTORE and RECOVER commands for RMAN restore and recovery of physical database files. Restoring datafiles is retrieving them from backups as needed for a recovery operation. Recovery is the application of changes from redo logs and incremental backups to a restored datafile, to bring the datafile to a desired SCN or point in time.

Recovering the Whole Database

Use the RESTORE DATABASE and RECOVER DATABASE commands on the whole database. For example:

RMAN> STARTUP FORCE MOUNT;
RMAN> RESTORE DATABASE;
RMAN> RECOVER DATABASE;
RMAN> ALTER DATABASE OPEN;

Note that the database must not be open when restoring or recovering the entire database.

Recovering Current Tablespaces

Use the RESTORE TABLESPACE and RECOVER TABLESPACE commands on individual tablespaces when the database is open. Take the tablespace that needs recovery offline, restore and then recover the tablespace, and bring the recovered tablespace online. The following steps recover the users tablespace:

RMAN> SQL 'ALTER TABLESPACE users OFFLINE';
RMAN> RESTORE TABLESPACE users;
RMAN> RECOVER TABLESPACE users;
RMAN> SQL 'ALTER TABLESPACE users ONLINE';

Recovering Current Datafiles

Use the RESTORE DATAFILE and RECOVER DATAFILE commands on individual current datafiles when the database is open. Take the datafile that needs recovery offline, restore and recover the datafile, and bring the datafile online. For example, to restore and recover datafile 7:

RMAN>   SQL 'ALTER DATABASE DATAFILE 7 OFFLINE';
RMAN>   RESTORE DATAFILE 7;
RMAN>   RECOVER DATAFILE 7;
RMAN>   SQL 'ALTER DATABASE DATAFILE 7 ONLINE';

Recovering Individual Data Blocks

RMAN can recover individual corrupted datafile blocks. When RMAN performs a complete scan of a file for a backup, any corrupted blocks are listed in V$DATABASE_BLOCK_CORRUPTION. Corruption is usually reported in alert logs, trace files or results of SQL queries. Use BLOCKRECOVER to repair all corrupted blocks:

RMAN> BLOCKRECOVER CORRUPTION LIST;

You can also recover individual blocks, as shown in this example:

RMAN> BLOCKRECOVER DATAFILE 7 BLOCK 233, 235 DATAFILE 4 BLOCK 101;

Validating Restores

You can run a RESTORE... VALIDATE operation to confirm that a restore operation can be performed successfully. RMAN decides which backup sets, datafile copies, and archived logs are needed for the operation, and scans them to verify that they are usable. For example:

RMAN> RESTORE DATABASE VALIDATE;