Backup Recovery   «Prev  Next»

Lesson 8 Perform database recovery with line command RMAN
Objective Use line command RMAN to recover a failed database.

Perform Database Recovery using the RMAN "Line Command"

You can use the RMAN line command to recover a failed database in Oracle 12c. The following steps outline how to do this:
  1. Start RMAN.
  2. Connect to the target database.
  3. Restore the database from the most recent backup.
  4. Recover the database to the desired point in time.
  5. Open the database.

Here is an example of the RMAN line commands that you would use to recover a failed database:
RMAN> connect target /;
RMAN> restore database;
RMAN> recover database to timestamp '2023-11-13 06:00:00';
RMAN> alter database open;

You can also use the RMAN line command to recover a failed database from a specific backup set. To do this, you would use the `RESTORE DATABASE FROM BACKUPSET` command. For example, the following RMAN line command would restore the database from the backup set named `backupset1`:
RMAN > restore database from backupset 'backupset1';

Once you have restored the database, you can use the `RECOVER DATABASE` command to recover the database to the desired point in time. It is important to note that you should always test your recovery procedures before using them in a production environment. You can do this by creating a test database and practicing recovering it.

Recovering from failure

Backing up the database is the easy part. The real challenge begins when the "ORA-01113 file needs recovery" message flashes on your console. Fortunately, using RMAN for recovery is as simple as backing up in the first place. Just as only a few commands are required to back up the database, it takes only a few commands to restore it:

Error "ORA-01113 file needs recovery"

The error "ORA-01113 file needs recovery" still exists for the Oracle RDBMS. This error occurs when a data file needs to be recovered before the database can be opened. This can happen if the data file has been corrupted or if the database has been shut down unexpectedly. There are a few things that you can do to resolve the ORA-01113 error:
  1. Restore the data file from a backup. This is the most common way to resolve this error. You can use the RMAN utility to restore the data file from a backup that was created before the error occurred.
  2. Use the RMAN RECOVER DATAFILE command to recover the data file. This command will attempt to repair the data file and make it consistent with the rest of the database.
  3. Use the REPAIR CATALOG command to repair the database catalog. This command will check the database catalog for errors and attempt to correct them.

If you are unable to resolve the ORA-01113 error, you may need to contact Oracle support for assistance. Here are some tips to avoid the ORA-01113 error:
  • Make sure to back up your database regularly.
  • Shut down the database cleanly whenever possible.
  • Use the RMAN utility to verify your backups regularly.
  • Use the RMAN utility to repair your database catalog regularly.

6> }

To restore the Database to its Present Location

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



If the database is open, shut it down, and then mount it:

After allocating the channels, restore the database:

Once the database is restored, open the database.
The following simulation uses RMAN to recover a failed database.

Recovering Database (line mode)

  1. You have connected to both RMAN and the target database by using RMAN as the User Name, RMAN as the Password, and BACKUP as the Host String. At the RMAN prompt, you have started the script and allocated the channel (C1) to back up the database. Now restore the database by typing RESTORE DATABASE and pressing Enter.
  2. We have released the channel and closed the statement for you by adding the end bracket. Now execute the statement by pressing Enter.
  3. We have released the channel and closed the statement for you by adding the end bracket. Now execute the statement by pressing Enter.
  4. RMAN now displays the result of executing the statement. Now that the database is recovered, open it by typing

    and pressing Enter.
  5. Now you can see that the database has been opened. This is the end of the simulation. Click Exit.

Recovery Manager in Command-line Mode

Recovery Manager in command-line mode is an Oracle9i tool that manages backing up, restoring, and recovering files. Recovery Manager is automatically installed with Oracle Utilities. Recovery Manager uses a special PL/SQL interface to the server for invoking backup functions. This interface operates invisibly; you will interface only with a command line. When RMAN needs to resynchronize from a read-consistent version of the control file, it creates a temporary snapshot control file. The default location of this file on Windows is

You must clearly understand the command-line syntax described in Oracle9i Recovery Manager Reference before using this tool. Backing up to tape requires an optional MML from a third-party vendor.

The next lesson shows how to restore a tablespace, control file, and archived log files by using RMAN.