Restore and recover the whole Database: RMAN> RMAN> RMAN> RMAN> STARTUP FORCE MOUNT; RESTORE DATABASE;

RECOVER DATABASE; ALTER DATABASE OPEN;

Restore and recover a Tablespace: RMAN> RMAN> RMAN> RMAN> SQL 'ALTER TABLESPACE users OFFLINE'; RESTORE TABLESPACE users; RECOVER TABLESPACE users; SQL 'ALTER TABLESPACE users ONLINE';

Restore and recover a Datafile: RMAN> RMAN> RMAN> RMAN> SQL 'ALTER DATABASE DATAFILE 64 OFFLINE'; RESTORE DATAFILE 64; RECOVER DATAFILE 64; SQL 'ALTER DATABASE DATAFILE 64 ONLINE';

Restore the Control file, (to all locations specified in the parameter file) then restore the database, using that control file: STARTUP NOMOUNT; RUN { ALLOCATE CHANNEL c1 DEVICE TYPE sbt; RESTORE CONTROLFILE; ALTER DATABASE MOUNT; RESTORE DATABASE; } Restore Validation confirms that a restore could be run, by confirming that all database files exist and are free of physical and logical corruption, this does not generate any output. Example:

.) Ensure you have enough disk space for both the backup files plus the restored database files.if neccecary use Symbolic Links (or in Windows use disk manager to re-assign drive letters.RMAN> RESTORE DATABASE VALIDATE. You will need the following information: Database SID: ________ Database SYS password: ________ Disk layout and sizes: ________ Database ID (DBID): ________ There are 5 steps to recover the database: 1) Create a new (empty) database instance 2) Mount the instance 3) Restore the datafiles 4) Recover the database 5) Reset the logs 1) Create a new (empty) database instance Configure the new server with same disk layout as the original database . There are many ways to restore a database using an RMAN backup .this example assumes you are performing a DisasterRecovery restore of all data and recovering the entire database with the same SID and the same disk/tablespace layout.

SQL> Startup mount. SQL> Startup mount pfile=C:\oracle\Database\initLive. or specifying the pfile explicitly: SQL> CREATE PFILE='C:\oracle\Database\initLive.ora 3) Restore the datafiles In this case we have copied the RMAN backup files and archive logs to R:\Rman\ Change the dbid to match that of the database being restored RMAN> SET dbid = 477771234. The ORAPWD utility can also be used to change the SYS password.ora' FROM SPFILE. SQL> Shutdown immediate. set the LOG_ARCHIVE_FORMAT parameter to match the setting in the original database. If the database to be restored is in archive log mode. . 2) Mount the empty instance SQL> Shutdown immediate. RMAN> run { ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT 'R:\Rman\%U'.Create a new database with the database configuration assistant (DBCA) and set the SYS password and global database_name to the same as the original database.

SQL> cancel 5) Reset the logs SQL> alter database open resetlogs. Notes: The DBID can be retrieved in several places. For a large database it can take a long time to restore each tablespace . As soon as you have done a resetlogs run a full backup.restore database. 4) Recover the database SQL> Recover from 'L:\oradata\live' database until cancel using backup controlfile. This will update all current datafiles and online redo logs and all subsequent archived redo logs with a new RESETLOGS SCN and time stamp. this is important as should you suffer a second failure you will not be able to perform a second recovery because after resetting the logs the SCN numbers will no longer match any older backup files. if the database is running: Select dbid from V$DATABASE. The RMAN client displays the dbid at startup when connecting to a database: . } At this point the datafiles and tablespaces will be re-created.for better performance during a restore place the RMAN backup files on a separate disk to the Oracle datafiles to reduce disk contention.

2003. You will need the following information: Database SID: ________ Database SYS password: ________ The Date and Time to restore to : ________ There are 5 steps to recover the database: 1) Restore backup files from tape 2) Mount the instance 3) Restore the datafiles 4) Recover the database 5) Reset the logs Restore backup files from tape If you are looking to restore the database to a time of (say 09:00) you will need the most recent RMAN backup files prior to the .Copyright (c) 1995. point-in time is probably the most common recovery scenario.this example assumes you are running RMAN without a Catalog and are performing a Restore & Point-In-Time Recovery of all data back to a particular date/time in the past. Oracle. ofter recovering the database right back to the time when you started the restore operation! If you are running in Archive log mode (and you should be). All rights reserved. connected to target database: RDBMS (DBID=7776644123) There are many ways to restore a database using an RMAN backup . If you are running in Archive log mode and recover without specifying a date/time then RMAN will apply all Archived logs it can find.

Restore and recover the datafiles RMAN> run { allocate channel dev1 type disk. restore database. Mount the instance C:\> Set ORACLE_SID=Live C:\> rman TARGET SYS/Password NOCATALOG RMAN:> shutdown immediate. RMAN:> startup mount. 'yyyy-dd-mm:hh24:mi:ss')".g. set until time "to_date('2010-30-12:00:00:00'. If any of these files have been moved (e. recover database. This will update all current datafiles and online redo logs and all subsequent archived redo logs with a new RESETLOGS SCN and time stamp. in this case from 23:00 until 09:00. } For a large database it can take a long time to restore each tablespace . Open the database and reset logs RMAN> alter database open resetlogs. .date (say 23:00 from the previous day) plus all the archive logs from the backup time until the restore time. archived to tape) restore them to the default locations on the oracle database server.for better performance during a restore place the RMAN backup files on a separate disk to the Oracle datafiles to reduce disk contention.

. Configure RMAN to back up the control file after each backup RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON. this is important as should you suffer a second failure you will not be able to perform a second recovery because after resetting the logs the SCN numbers will no longer match any older backup files. Backup using a flash recovery area rather than disk RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT CLEAR. Example Change an ordinary backup into a long-term backup: CHANGE BACKUPSET 431 KEEP FOREVER NOLOGS. Examples Show all configurable settings: RMAN>SHOW ALL.As soon as you have done a resetlogs run a full backup. Write disk backups to the /tmp directory: (%U will be replaced with unique filenames) RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/tmp/%U'.

. Ensure that RMAN retains all backups needed to recover the database to any point in time in the last 7 days: RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS. Reset any CONFIGURE setting to its default by running the command with the CLEAR option RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt CLEAR. Delete backups no longer required by the retention policy: RMAN> DELETE OBSOLETE To override the configured retention policy for individual backups ... To configure RMAN to write control file backups to the /cfilebackups directory: ( %F will generate a unique filename) RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/cfilebackups/cf%F'.By default. KEEP (or CHANGE.use BACKUP. KEEP) Configure backups to run in parallel by assigning two sbt channels: RMAN> CONFIGURE DEVICE TYPE sbt PARALLELISM 2. Retain three backups of each datafile: RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 3. RMAN automatically names control file backups and stores them in the flash recovery area.

day. and sequence number. Syntax: RUN { . MAXSETSIZE. SHOW { RETENTION POLICY | [DEFAULT] DEVICE TYPE | [AUXILIARY] CHANNEL [FOR DEVICE TYPE deviceSpecifier] | MAXSETSIZE | { DATAFILE | ARCHIVELOG } BACKUP COPIES | BACKUP OPTIMIZATION | SNAPSHOT CONTROLFILE NAME | AUXNAME | EXCLUDE | CONTROLFILE AUTOBACKUP [FORMAT] | ALL }. } .RMAN> CONFIGURE RETENTION POLICY CLEAR. CHANNEL. DEVICE TYPE.. Examples SHOW SHOW SHOW SHOW SHOW RETENTION POLICY. DEFAULT DEVICE TYPE. year. Unique filenames are: DBID.. month. SHOW ALL.

} Examples Restore and recover the whole database RMAN> STARTUP FORCE MOUNT. RMAN> RECOVER DATABASE. Restore and recover a tablespace RMAN> SQL 'ALTER TABLESPACE users OFFLINE'. RMAN> RESTORE DATABASE. .marketing FILESPERSET 20) (DATAFILE 62.finance.Example RUN { ALLOCATE CHANNEL dev1 DEVICE TYPE DISK FORMAT '/fs1/%U'.64). RMAN> RECOVER TABLESPACE users. RMAN> RECOVER DATAFILE 64. RMAN> RESTORE TABLESPACE users. Mount or open the database. ALLOCATE CHANNEL dev2 DEVICE TYPE DISK FORMAT '/fs2/%U'. Restore and recover a datafile RMAN> SQL 'ALTER DATABASE DATAFILE 64 OFFLINE'.63. RMAN> ALTER DATABASE OPEN. RMAN> SQL 'ALTER TABLESPACE users ONLINE'. BACKUP (TABLESPACE system. RMAN> RESTORE DATAFILE 64. Steps for media recovery: 1. Mount the database when performing whole database recovery. RMAN> SQL 'ALTER DATABASE DATAFILE 64 ONLINE'.

3. Recover the datafiles with the RECOVER command. SCN. use the SET UNTIL command to specify the time. or log sequence number at which recovery terminates. 5.dbf'. Backup datafiles: RMAN> BACKUP AS BACKUPSET DATAFILE 'ORACLE_HOME/oradata/trgt/users01. Syntax: BACKUP FULL Options BACKUP FULL AS (COPY | BACKUPSET) Options BACKUP INCREMENTAL LEVEL [=] integer Options BACKUP INCREMENTAL LEVEL [=] integer AS (COPY | BACKUPSET) Options BACKUP AS (COPY | BACKUPSET) Options BACKUP AS (COPY | BACKUPSET) (FULL | INCREMENTAL LEVEL [=] integer) Options Examples Back up the database.or open the database when performing online tablespace recovery. Restore the necessary files with the RESTORE command.dbf'. Alternatively. . 4. 2. To perform incomplete recovery. Place the database in its normal state. open it or bring recovered tablespaces online. specify the UNTIL clause on the RESTORE and RECOVER commands. RMAN> BACKUP CURRENT CONTROLFILE. 'ORACLE_HOME/oradata/trgt/tools01. and then the control file: (which contains a record of the backup) RMAN> BACKUP DATABASE. For example.

RMAN> BACKUP DATABASE UNTIL 'SYSDATE+365' NOLOGS. Example: RMAN> BACKUP VALIDATE DATABASE ARCHIVELOG ALL. RMAN> STARTUP MOUNT. Backup archive logs: RMAN> BACKUP ARCHIVELOG COMPLETION TIME BETWEEN 'SYSDATE-28' AND 'SYSDATE-7'. this does not generate any output. by confirming that all database files exist and are free of physical and logical corruption. created on disk) RMAN> BACKUP AS COPY DATABASE. Backup controlfile: RMAN> BACKUP CURRENT CONTROLFILE TO '/backup/cntrlfile. .copy'. tools.Backup all datafiles in the database: (bit-for-bit copies. Backup Validation confirms that a backup could be run. Backup everything: RMAN> BACKUP BACKUPSET ALL. Backup tablespace: RMAN> BACKUP TABLESPACE system. Create a consistent backup and keep the backup for 1 year: (exempt from the retention policy) RMAN> SHUTDOWN. Backup parameter file: RMAN> BACKUP SPFILE. users.

BACKUP OF DATABASE. BACKUP BY FILE. BACKUP SUMMARY. 2. CONTROLFILECOPY "/tmp/cntrlfile. BACKUP OF DATAFILE 11 SUMMARY. 3. backup of controlfile. COPY OF DATAFILE 1. COPY OF DATABASE ARCHIVELOG ALL. backup of database. BACKUP OF ARCHIVELOG FROM SEQUENCE 1437. INCARNATION. archivelog all. COPY. BACKUPSET OF DATAFILE 1. . RMAN> RMAN> RMAN> RMAN> RMAN> CROSSCHECK CROSSCHECK CROSSCHECK CROSSCHECK CROSSCHECK BACKUP.copy".RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST BACKUP.

Sign up to vote on this title
UsefulNot useful