Skip Headers

Oracle9i Recovery Manager Reference
Release 2 (9.2)

Part Number A96565-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

RMAN Commands , 46 of 59


RESTORE

Syntax

Text description of rcmsynta18.gif follows
Text description of the illustration rcmsynta18.gif


restoreObject::=
Text description of restoreObject.gif follows
Text description of the illustration restoreObject.gif


restoreSpecOperand::=
Text description of restoreSpecOperand.gif follows
Text description of the illustration restoreSpecOperand.gif


Purpose

To restore files from backups or image copies. By default, RMAN restores files to their default location. You can use the SET NEWNAME command to restore files to nondefault locations. RMAN restores backups from disk or tape and restores images copies from disk only.

Typically, you restore when a media failure has damaged a current datafile, control file, or archived log or prior to performing a point-in-time recovery. The RESTORE command restores full backups, incremental backups (level 0 only), or copies of datafiles, control files, and archived redo logs. Because the RECOVER command automatically restores archived logs as needed, you should seldom need to restore logs manually. Possible reasons for manually restoring archived logs are to speed up recovery or to stage the logs to multiple destinations.


Note:

In Oracle9i, unlike in previous RMAN releases, RMAN by default does not restore a datafile if the file is in the correct place and its header contains the expected data (RMAN does not scan the datafile body for corrupt blocks). The FORCE option overrides this behavior and restores the requested files unconditionally.


When you run RESTORE in CATALOG mode with a backup control file, RMAN automatically adjusts the control file to reflect the structure of the restored database.

If you restore to the default location, then RMAN overwrites files with the same filenames. If you restore to a new location, then issue SET NEWNAME commands to rename the files and issue a SWITCH command to make the restored files current. If you do not issue SWITCH commands, then RMAN considers the restored files as valid copies for use in future restore operations.

If you do not manually allocate channels, then RMAN allocates all automatic channels possibly needed by the RESTORE command. For example, assume you configure 3 separate sbt channels (each with different PARMS) and then configure parallelism for DISK and sbt as follows:

CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
CONFIGURE DEVICE TYPE sbt PARALLELISM 3;
CONFIGURE DEFAULT DEVICE TYPE TO sbt;

During a restore, RMAN allocates three sbt channels and the two preconfigured DISK channels. For a restore, RMAN allocates all configured channels unless the DEVICE TYPE option restricts the device type from which RMAN restores files.

In a Real Application Clusters configuration, RMAN automatically restores backups, control file copies, and datafile copies from channels that can read the files on tape or a local file system. For example, if channel 1 connected to instance 1 can read log 1000 from its tape drive, but channel 2 connected to instance 2 cannot read the log from its tape drive, then channel 1 restores the log. Autolocation is automatically enabled when the channels meet any of the following criteria:

Restrictions and Usage Notes

Restrictions and Usage Notes for RESTORE CONTROLFILE

Table 2-25 indicates the restrictions that apply in different situations involving the RESTORE CONTROLFILE command.

Table 2-25 RESTORE CONTROLFILE Scenarios
RESTORE CONTROLFILE; RESTORE CONTROLFILE FROM AUTOBACKUP; RESTORE CONTROLFILE ... TO 'filename'; RESTORE CONTROLFILE ... FROM 'media_handle' or TAG;

No catalog, target started

Error. Must specify FROM AUTOBACKUP.

First run SET DBID. Restores to CONTROL_FILES locations.

First run SET DBID. Must specify FROM AUTOBACKUP. Restores only to filename.

First run SET DBID. Restores from specified file (cannot restore from TAG). If TO 'filename' not used, restores to all CONTROL_FILES locations.

No catalog, target mounted or open

Error. Must use TO 'filename', where filename is not in CONTROL_FILES list.

Error. Must use TO 'filename', where filename is not in CONTROL_FILES list.

Restores only to filename, where filename is not in CONTROL_FILES list.

Restores from specified file. If TO 'filename' not used, restores to all CONTROL_FILES locations.

Catalog, target started

Restores to CONTROL_FILES locations. Run SET DBID only if
DB_NAME not unique in catalog.

Do not use with catalog unless for testing purposes.

Restores only to filename, where filename is not in CONTROL_FILES list.

Restores from specified file. If TO 'filename' not used, restores to all CONTROL_FILES locations.

Catalog, target mounted or open

Error. Must use TO 'filename', where filename is not in CONTROL_FILES list.

Do not use with catalog.

Restores only to filename, where filename is not in CONTROL_FILES list.

Restores from specified file. If TO 'filename' not used, restores to all CONTROL_FILES locations.

Keywords and Parameters

Syntax Element Description

restoreObject

Specifies the objects to be restored.

CONTROLFILE

Restores the current control file.

See Also: Table 2-25 for restrictions and usage notes.

Note: You must always run the RECOVER command after restoring a control file, and must also always open the database with the RESETLOGS option.

DATABASE

Restores all datafiles in the database except those that are offline or read-only. Unlike BACKUP DATABASE, RESTORE DATABASE does not automatically include the control file and the server parameter file--you must issue additional RESTORE CONTROLFILE and RESTORE SPFILE commands to restore these files.

If you specify the CHECK READONLY option, then RMAN examines the headers of all read-only datafiles and restores any that need restoring.

Use an optional SKIP TABLESPACE 'tablespace_name' argument to avoid restoring specified tablespaces, which is useful when you want to avoid restoring tablespaces containing temporary data.

If you specify SKIP FOREVER TABLESPACE, then RMAN specifies the DROP option of ALTER DATABASE DATAFILE ... OFFLINE when taking the datafiles that belong to the tablespace offline before the restore. The DROP option indicates that RMAN does not intend to recover these files and intends to drop their tablespaces from the database after the database is opened again. In other words, FOREVER indicates that RMAN never intends to do anything with the skipped tablespaces again.

DATAFILE datafileSpec

Restores the datafiles specified by filename or absolute datafile number.

See Also: "datafileSpec"

TABLESPACE 'tablespace_name'

Restores all datafiles in the specified tablespaces.

Restores the specified range of archived redo logs.

See Also: "archivelogRecordSpecifier"

Note: The database can be started, mounted, or open for this operation.

SPFILE [TO [PFILE] 'filename']

Restores the server parameter file to the location from which it was backed up (default). Alternatively, you can specify a different location with the TO clause. RMAN cannot overwrite a server parameter file currently in use by the target database.

Specify UNTIL or TAG options of RESTORE command to restore older versions of the server parameter file. By default RMAN restores the most current server parameter file.

If the server parameter file is lost, connect to the target (and catalog if used) and then run SET DBID. Run STARTUP FORCE NOMOUNT before running RESTORE SPFILE (with FROM AUTOBACKUP if in NOCATALOG mode). Then run STARTUP FORCE to restart the database with the restored server parameter file.

See Also: "Restrictions and Usage Notes for the SET DBID Command"

restoreSpecOperand

specifies options for the restoreObject clause.

Note: These parameters override the parameters with the same name at the RESTORE command level.

CHANNEL 'channel_id'

Specifies the case-sensitive name of a channel to use for this restore operation. If you do not specify a channel, then RESTORE uses any available channel allocated with the correct device type.

FROM TAG = 'tag_name'

Overrides the default selection of the most recent backups or file copy available. The tag restricts the automatic selection to backup sets or file copies that were created with the specified tag. If multiple backup sets or file copies have a matching tag, then RMAN selects the most recent one. Note that tag names are not case sensitive.

See Also: "BACKUP" for a description of how a tag can be applied to an individual copy of a duplexed backup set, and for a description of the default filename format for tags

PARMS 'channel_parms'

Specifies a quoted string containing operating system-specific information. The string is passed to the operating system dependent layer each time a backup piece is restored.

FROM AUTOBACKUP

Restores a control file autobackup. You can only specify this option on the RESTORE CONTROLFILE and RESTORE SPFILE commands. When restoring either type of file in NOCATALOG mode, the FROM AUTOBACKUP clause is required.

RMAN begins the search on the current day or on the day specified with the SET UNTIL. If no autobackup is found in the current or SET UNTIL day, RMAN checks the previous day starting with sequence 256 (or the sequence specified by MAXSEQ) until it reaches 0. The search continues up to MAXDAYS days (default of 7, maximum of 366) from the current or SET UNTIL day. If no autobackup is found within MAXDAYS days, then RMAN signals an error and the command stops.

See Also: Table 2-25 for restrictions and usage notes.

FROM 'media_handle'

Specifies the name of the control file copy or backup piece containing a control file. The media_handle can be any backup piece that contains a backup of a control file: the control file backup does not need to be an autobackup.

See Also: Table 2-25 for restrictions and usage notes.

CHANNEL 'channel_id'

Refer to the restoreSpecOperand clause.

PARMS 'channel_parms'

Refer to the restoreSpecOperand clause.

FROM {BACKUPSET | DATAFILECOPY}

Specifies whether RMAN should restore from a DATAFILECOPY on disk or a BACKUPSET. By default RESTORE chooses the most recent backup set or file copy, that is, the file copy or backup set that needs the least media recovery.

untilClause

Limits the selection to those backup sets or file copies that would be suitable for performing an incomplete recovery to the specified time. In the absence of any other criteria, RMAN selects the most current file copy or backup set to restore.

See Also: "untilClause"

FROM TAG = 'tag_name'

Refer to the restoreSpecOperand clause.

VALIDATE

Causes RMAN to decide which backup sets, datafile copies, and archived logs need to be restored and then scans them to verify their contents. This operation creates no output files. Specify this option periodically to verify that the copies and backup sets required to restore the specified files are intact and usable.

CHECK LOGICAL

Tests data and index blocks that pass physical corruption checks for logical corruption, for example, corruption of a row piece or index entry. If RMAN finds logical corruption, it logs the block in the alert.log and server session trace file.

If the sum of physical and logical corruptions for a file remain below its MAXCORRUPT setting, the RMAN command completes and Oracle populates the V$DATABASE_BLOCK_CORRUPTION view with corrupt block ranges. If MAXCORRUPT is exceeded, the command terminates without populating the views.

Note: The MAXCORRUPT setting represents the total number of physical and logical corruptions permitted on a file.

CHECK READONLY

Checks the read-only datafiles to make sure they exist, are readable, and have the appropriate checkpoint. If any of these conditions is not met, then RMAN restores the files--whether or not they are read-only. By default, RMAN does not restore read-only files when you issue the RESTORE DATABASE command.

DEVICE TYPE deviceSpecifier

Allocates automatic channels for the specified device type only. For example, if you configure automatic disk and tape channels, and issue RESTORE ... DEVICE TYPE DISK, then RMAN allocates only disk channels.

See Also: "deviceSpecifier"

FORCE

Overrides the restartable restore feature and restores all files regardless of whether they need to be restored. If you do not specify FORCE, then RMAN restores a file only if its header information does not match the information in the control file.

Examples

Restoring a Tablespace: Example

This example takes a tablespace offline, restores it, then performs media recovery:

SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE"; 
RESTORE TABLESPACE users; 
RECOVER TABLESPACE users;  
SQL "ALTER TABLESPACE users ONLINE";
Restoring the Control File When Using a Recovery Catalog: Example

This example restores the control file to its default location, replicates it automatically to all CONTROL_FILES locations, and mounts the database:

RUN
{ # SET DBID is not necessary when connected to a recovery catalog
  STARTUP FORCE NOMOUNT;
  RESTORE CONTROLFILE;
  ALTER DATABASE MOUNT;
}
Restoring the Control File with a Tag: Example

This NOCATALOG example restores the control file specified by a tag, and then mounts the database:

CONNECT TARGET /
STARTUP NOMOUNT;
SET DBID 320066378;  # required when restoring control file in NOCATALOG mode
RESTORE CONTROLFILE FROM TAG 'monday_cf_backup';
ALTER DATABASE MOUNT;
Restoring the Database with a Backup Control File: Example

This example restores the control file, replicates it to all control file locations specified in the parameter file, and then restores and recovers the database:

CONNECT TARGET /
STARTUP NOMOUNT;
SET DBID 320066378;  # required when restoring control file in NOCATALOG mode
RUN
{
  ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
  RESTORE CONTROLFILE TO '/tmp/control01.ctl' FROM AUTOBACKUP;
  RESTORE CONTROLFILE FROM '/tmp/control01.ctl'; # restores to all CONTROL_FILES locations
  ALTER DATABASE MOUNT;
  RESTORE DATABASE;
  RECOVER DATABASE;
}
ALTER DATABASE OPEN RESETLOGS;
# if the database uses locally-managed temporary tablespaces, then add new tempfiles
# to these tablespaces after the RESETLOGS
SQL "ALTER TABLESPACE temp ADD TEMPFILE ''?/oradata/trgt/temp01.dbf'' REUSE";
Restoring Archived Redo Logs to a New Location: Example

This example restores all archived redo logs to the /oracle/temp_restore directory:

RUN
{ 
  SET ARCHIVELOG DESTINATION TO '/tmp';
  RESTORE ARCHIVELOG ALL;
}
Restoring a Control File Autobackup to a Nondefault Location: Example

This example restores the latest control file autobackup made on or before June 23, 2000 with a nondefault format of PROD_CF_AUTOBACKUP_%F. It starts searching for backups with a sequence number of 20, and searches backward for 5 months:

SET DBID 320066378;  # required when restoring control file in NOCATALOG mode
RUN
{
  SET UNTIL TIME '23-JUN-2001 00:00:00';
  SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE sbt TO 'prod_cf_autobackup_%F';
  ALLOCATE CHANNEL CHANNEL_1 DEVICE TYPE sbt;
  RESTORE CONTROLFILE TO '/tmp/autobackup_20001002.dbf' FROM AUTOBACKUP 
    MAXSEQ 20 MAXDAYS 150;
}
Restoring the Server Parameter File to Current Location: Example

The following shell script restores the current server parameter file in NOCATALOG mode:

#!/usr/bin/tcsh
rman TARGET / <<EOF
SET DBID 1447326980 # set dbid to dbid of target database
STARTUP FORCE NOMOUNT; # start instance with dummy SPFILE
RUN
{
  ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
  RESTORE SPFILE FROM AUTOBACKUP; # FROM AUTOBACKUP needed in NOCATALOG mode
}
STARTUP FORCE; # start with restored SPFILE and open database
EXIT
EOF
Restoring the Server Parameter File to a Nondefault Location: Example

The following shell script restores a server parameter file that was backed up at least a month ago and restarts the database with the restored parameter file:

#!/usr/bin/tcsh
echo "SPFILE=/tmp/spfileTEMP.ora" > /tmp/initTEMP.ora
rman TARGET / <<EOF
STARTUP FORCE MOUNT; # make sure database is mounted so SET DBID not required
RESTORE SPFILE TO '/tmp/spfileTEMP.ora' UNTIL 'SYSDATE-31';
STARTUP FORCE PFILE=/tmp/initTEMP.ora; # start with restored SPFILE and open database
EXIT
EOF

Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback