Server-managed recovery consists of using the RMAN utility, which Oracle recommends for performing both backup and recovery processes. RMAN recovery is often termed server-manager recovery because the recovery is performed by a server process that initiates the recovery process. Figure 4.2 shows the server-managed recovery process.
The first process is using the RESTORE command, which restores datafiles, tablespaces, control files, archived redo logs, and server parameter files from disk or tape. The RESTORE command is required with all backups made from the BACKUP command to create backups. The BACKUP command stores backups in a proprietary RMAN format called a BACKUPSET. If using the BACKUP AS COPY command, the RESTORE command is not required.
The RECOVER command is required with the BACKUP or BACKUP AS COPY command to roll the backup forward. The RECOVER command is responsible for applying the archived redo logs to the restored data files, if necessary, to apply the changes in the database that are not in the restored database files.
Let's walk through using the RESTORE and RECOVER command to restore a database from backup:
First, the target database must be in a mounted state to perform a full database recovery. The database can be open if you are performing online tablespace recovery or something less than full database recovery:
C:Documents and Settingsdstuns> sqlplus /nolog SQL*Plus: Release 10.1.0.2.0 - Production on Fri Sep 3 21:23:44 2004 Copyright (c) 1982, 2004, Oracle. All rights reserved.
SQL> connect / as sysdba Connected. SQL> startup mount ORACLE instance started. Total System Global Area 88080384 bytes Fixed Size 787588 bytes Variable Size 78642044 bytes Database Buffers 8388608 bytes Redo Buffers 262144 bytes Database mounted.
Next, run the RESTORE DATABASE and RECOVER DATABASE commands:
RMAN> run 2> { 3> allocate channel c1 type disk; 4> restore database; 5> recover database; 6> alter database open; 7> } using target database controlfile instead of recovery catalog allocated channel: c1 channel c1: sid=49 devtype=DISK Starting restore at 03-SEP-04 channel c1: starting datafile backupset restore channel c1: specifying datafile(s) to restore from backup set restoring datafile 00001 to C:ORACLEORADATAORA101TSYSTEM01.DBF restoring datafile 00002 to C:ORACLEORADATAORA101TUNDOTBS01.DBF restoring datafile 00003 to C:ORACLEORADATAORA101TSYSAUX01.DBF restoring datafile 00004 to C:ORACLEORADATAORA101TUSERS01.DBF restoring datafile 00005 to C:ORACLEORADATAORA101TEXAMPLE01.DBF restoring datafile 00006 to C:ORACLEORADATAORA101TINDEX01.DBF channel c1: restored backup piece 1
piece handle=C:ORACLEFLASH_RECOVERY_AREAORA101TORA101TBACKUPSET 2004_09_03O1_MF_NNNDF_TAG20040903T213632_0MLKLMH2_.BKP tag=TAG20040903T213632 channel c1: restore complete Finished restore at 03-SEP-04 Starting recover at 03-SEP-04 starting media recovery media recovery complete Finished recover at 03-SEP-04 database opened released channel: RMAN>
As you can see, the RESTORE command restored the datafiles from BACKUPSET. The RECOVER command then determines if any archived redo logs need to be applied. If so, these are applied to the database to make it consistent or to the point-in-time determined in the recovery process.