Thursday, January 15, 2009

Duplicating a Database using RMAN - (UNIX / Linux)

Contents

  1. Overview
  2. Pre-requisites
  3. Steps Required

 


Overview

This article provides a quick introduction on how to duplicate a database using the RMAN DUPLICATE DATABASE command on the UNIX / Linux operating environment. For this demonstration, we will create a duplicate target database using RMAN's DUPLICATE DATABASE command to the same host (localhost) of the target database.

Please keep in mind that this article should not be considered a substitution for completing reading and understanding the official documentation and release notes from Oracle. The following links can be used to download the Recovery Manager User's Guide for Oracle9i (9.2.0):

  Oracle9i Database Release 2 Documentation
  Oracle9i Recovery Manager User's Guide - (A96566-01)

Here is a short introduction to some of the configuration parameters that will be used for installing the Oracle RDBMS Software:

Operating Environment

Red Hat Linux - Fedora Core 2

Oracle Release / Version

9.2.0.5.0 Enterprise Edition

ORACLE_BASE

/u01/app/oracle

ORACLE_HOME

/u01/app/oracle/product/9.2.0

Target Database SID

ORA920

Duplicate Database SID

TESTDB

RMAN Catalog Database

No recovery catalog. Using control file.

Archive Log Mode

Enabled

log_archive_dest_1

location=/u06/app/oradata/ORA920/archive mandatory

log_archive_dest_state_1

enable

log_archive_format

arch_t%t_s%s.dbf

log_archive_start

true

RMAN Default Configuration Settings

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/orabackup/ORA920/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/orabackup/ORA920/backup_DB_%d_S_%s_P_%s_T_%t';
RMAN configuration has no stored or default parameters
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/9.2.0/dbs/snapcf_ORA920.f'; # default

It is a common request to create a duplicated database from a production database. This can be easily achieved using the RMAN DUPLICATE command. Using the RMAN DUPLICATED command, the DBA can create a duplicate database from a target database's backup while still retaining the original target database. While it is possible to create a duplicate database that contains only a subset of the original database (by tablespace), this article will demonstrate how to create a completely identical database. Using this method allows you to test backup and recovery procedures as well as exporting data such as a table that was inadvertently dropped from the production database, and then importing it back into the production database.

 


Pre-requisites

A valid full database backup of the target database

RMAN> list backup summary;
 
List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Tag
------- -- -- - ----------- --------------- ------- ------- ---
14      B  A  A DISK        03-NOV-04       1       1       TAG20041103T163334
15      B  F  A DISK        03-NOV-04       1       1       TAG20041103T163336
16      B  A  A DISK        03-NOV-04       1       1       TAG20041103T163651
17      B  F  A DISK        03-NOV-04       1       1

Target database must be mounted or open

$ sqlplus "/ as sysdba"
 
SQL*Plus: Release 9.2.0.5.0 - Production on Wed Nov 3 16:42:34 2004
 
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
 
Connected to an idle instance.
 
SQL> startup open
ORACLE instance started.
 
Total System Global Area  252777660 bytes
Fixed Size                   451772 bytes
Variable Size             218103808 bytes
Database Buffers           33554432 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.
SQL> exit

 


Steps Required

  1. Create Password File for Auxiliary Database
$ orapwd file=/u01/app/oracle/product/9.2.0/dbs/orapwTESTDB password=change_on_install
  1. Create an Initialization Parameter for the Auxiliary Database

Copy the initialization parameter from the target database and make the necessary changes for the duplicated database.

$ export ORACLE_SID=ORA920
$ sqlplus "/ as sysdba"
 
SQL> create pfile='/u01/app/oracle/product/9.2.0/dbs/initTESTDB.ora' from spfile;
 
File created.

After creating the initialization parameter for the duplicate database, change at least the following parameters:

db_file_name_convert = ('/u06/app/oradata/ORA920', '/u06/app/oradata/TESTDB')
log_file_name_convert = ('/u03/app/oradata/ORA920', '/u03/app/oradata/TESTDB',
                         '/u04/app/oradata/ORA920', '/u04/app/oradata/TESTDB',
                         '/u05/app/oradata/ORA920', '/u05/app/oradata/TESTDB')
control_files = '/u03/app/oradata/TESTDB/control01.ctl'
              , '/u04/app/oradata/TESTDB/control02.ctl'
              , '/u05/app/oradata/TESTDB/control03.ctl'
db_name              = 'TESTDB'
instance_name        = 'TESTDB'
audit_file_dest      = '/u01/app/oracle/admin/TESTDB/adump'
background_dump_dest = '/u01/app/oracle/admin/TESTDB/bdump'
core_dump_dest       = '/u01/app/oracle/admin/TESTDB/cdump'
user_dump_dest       = '/u01/app/oracle/admin/TESTDB/udump'
service_names        = 'TESTDB.IDEVELOPMENT.INFO'
dispatchers          = '(PROTOCOL=TCP) (SERVICE=TESTDBXDB)'
log_archive_dest_1   = 'location=/u06/app/oradata/TESTDB/archive mandatory'
  1. Create / Start the Auxiliary Instance

Create all needed directories for the duplicate database:

$ mkdir /u01/app/oracle/admin/TESTDB
$ mkdir /u01/app/oracle/admin/TESTDB/adump
$ mkdir /u01/app/oracle/admin/TESTDB/bdump
$ mkdir /u01/app/oracle/admin/TESTDB/cdump
$ mkdir /u01/app/oracle/admin/TESTDB/create
$ mkdir /u01/app/oracle/admin/TESTDB/pfile
$ mkdir /u01/app/oracle/admin/TESTDB/scripts
$ mkdir /u01/app/oracle/admin/TESTDB/udump
 
$ mkdir /u03/app/oradata/TESTDB
$ mkdir /u04/app/oradata/TESTDB
$ mkdir /u05/app/oradata/TESTDB
$ mkdir /u06/app/oradata/TESTDB
$ mkdir /u06/app/oradata/TESTDB/archive
 
 
$ export ORACLE_SID=TESTDB
 
$ sqlplus "/ as sysdba"
 
SQL> startup nomount
  1. Ensure Oracle Net Connectivity to Auxiliary Database

Modify both the listener.ora and tnsnames.ora file to be able to connect to the auxiliary database. After making changes to the networking files, test the connection keeping in mind that you must be able to connect to the auxiliary instance with SYSDBA privileges, so a valid password file must exist.

$ sqlplus "sys/change_on_install@TESTDB as sysdba"
 
SQL*Plus: Release 9.2.0.5.0 - Production on Wed Nov 3 17:43:22 2004
 
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
 
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.5.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.5.0 - Production
 
SQL>
  1. Mount or Open the Target Database

As mentioned in the pre-requisites section of this article, the target database should be either opened or mounted.

$ export ORACLE_SID=ORA920
$ sqlplus "/ as sysdba"
SQL> startup open
  1. Ensure You Have the Necessary Backups and Archived Redo Log Files

As mentioned in the pre-requisites section of this article, ensure that you have a current backup that you wish to use to create the duplicate database. Login to query the RMAN catalog:

$ rman target sys/change_on_install@ORA920
 
RMAN> list backup summary;
 
List of Backups
===============
Key     TY LV S Device Type Completion Time #Pieces #Copies Tag
------- -- -- - ----------- --------------- ------- ------- ---
14      B  A  A DISK        03-NOV-04       1       1       TAG20041103T163334
15      B  F  A DISK        03-NOV-04       1       1       TAG20041103T163336
16      B  A  A DISK        03-NOV-04       1       1       TAG20041103T163651
17      B  F  A DISK        03-NOV-04       1       1
  1. Login to Target and Auxiliary Database using RMAN
8.           $ rman target sys/change_on_install@ORA920 auxiliary sys/change_on_install@TESTDB
9.            
10.       Recovery Manager: Release 9.2.0.5.0 - Production
11.        
12.       Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
13.        
14.       connected to target database: ORA920 (DBID=2542332757)
15.       connected to auxiliary database: TESTDB (not mounted)
16.        
RMAN>
  1. Run the RMAN DUPLICATE DATABASE Command

The following RUN block can be used to fully duplicate the target database from the latest full backup.

 

Note that you can duplicate the database to a specific date/time using the UNTIL TIME '<DATE>' clause. For example, to duplicate the new database to yesterdays date/time, use the following:

duplicate target database to TESTDB until time 'SYSDATE-1';.

run {
    # Allocate the channel for the duplicate work
    allocate auxiliary channel ch1 type disk;
 
    # Duplicate the database to TESTDB
    duplicate target database to TESTDB;
}
 
using target database controlfile instead of recovery catalog
allocated channel: ch1
channel ch1: sid=13 devtype=DISK
 
Starting Duplicate Db at 03-NOV-04
 
printing stored script: Memory Script
{
   set until scn  14757706;
   set newname for datafile  1 to "/u06/app/oradata/TESTDB/system01.dbf";
   set newname for datafile  2 to "/u06/app/oradata/TESTDB/undotbs1_01.dbf";
   set newname for datafile  3 to "/u06/app/oradata/TESTDB/cwmlite01.dbf";
   set newname for datafile  4 to "/u06/app/oradata/TESTDB/drsys01.dbf";
   set newname for datafile  5 to "/u06/app/oradata/TESTDB/indx01.dbf";
   set newname for datafile  6 to "/u06/app/oradata/TESTDB/odm01.dbf";
   set newname for datafile  7 to "/u06/app/oradata/TESTDB/tools01.dbf";
   set newname for datafile  8 to "/u06/app/oradata/TESTDB/users01.dbf";
   set newname for datafile  9 to "/u06/app/oradata/TESTDB/xdb01.dbf";
   set newname for datafile  10 to "/u06/app/oradata/TESTDB/example01.dbf";
   set newname for datafile  11 to "/u06/app/oradata/TESTDB/perfstat01.dbf";
   set newname for datafile  12 to "/u06/app/oradata/TESTDB/users02.dbf";
   restore
   check readonly
   clone database
   ;
}
executing script: Memory Script
 
executing command: SET until clause
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
executing command: SET NEWNAME
 
Starting restore at 03-NOV-04
 
channel ch1: starting datafile backupset restore
channel ch1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u06/app/oradata/TESTDB/system01.dbf
restoring datafile 00002 to /u06/app/oradata/TESTDB/undotbs1_01.dbf
restoring datafile 00003 to /u06/app/oradata/TESTDB/cwmlite01.dbf
restoring datafile 00004 to /u06/app/oradata/TESTDB/drsys01.dbf
restoring datafile 00005 to /u06/app/oradata/TESTDB/indx01.dbf
restoring datafile 00006 to /u06/app/oradata/TESTDB/odm01.dbf
restoring datafile 00007 to /u06/app/oradata/TESTDB/tools01.dbf
restoring datafile 00008 to /u06/app/oradata/TESTDB/users01.dbf
restoring datafile 00009 to /u06/app/oradata/TESTDB/xdb01.dbf
restoring datafile 00010 to /u06/app/oradata/TESTDB/example01.dbf
restoring datafile 00011 to /u06/app/oradata/TESTDB/perfstat01.dbf
restoring datafile 00012 to /u06/app/oradata/TESTDB/users02.dbf
channel ch1: restored backup piece 1
piece handle=/orabackup/ORA920/backup_DB_ORA920_S_16_P_16_T_541269216 tag=TAG20041103T163336 params=NULL
channel ch1: restore complete
Finished restore at 03-NOV-04
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TESTDB" RESETLOGS ARCHIVELOG
  MAXLOGFILES     32
  MAXLOGMEMBERS      5
  MAXDATAFILES      600
  MAXINSTANCES    10
  MAXLOGHISTORY     1134
 LOGFILE
  GROUP  1 ( '/u03/app/oradata/TESTDB/redo_g01a.log', '/u04/app/oradata/TESTDB/redo_g01b.log', '/u05/app/oradata/TESTDB/redo_g01c.log' ) SIZE  104857600
  REUSE,
  GROUP  2 ( '/u03/app/oradata/TESTDB/redo_g02a.log', '/u04/app/oradata/TESTDB/redo_g02b.log', '/u05/app/oradata/TESTDB/redo_g02c.log' ) SIZE  104857600
  REUSE,
  GROUP  3 ( '/u03/app/oradata/TESTDB/redo_g03a.log', '/u04/app/oradata/TESTDB/redo_g03b.log', '/u05/app/oradata/TESTDB/redo_g03c.log' ) SIZE  104857600
  REUSE
 DATAFILE
  '/u06/app/oradata/TESTDB/system01.dbf'
 CHARACTER SET WE8ISO8859P1
 
printing stored script: Memory Script
{
   switch clone datafile all;
}
executing script: Memory Script
datafile 2 switched to datafile copy
input datafilecopy recid=1 stamp=541274660 filename=/u06/app/oradata/TESTDB/undotbs1_01.dbf
datafile 3 switched to datafile copy
input datafilecopy recid=2 stamp=541274660 filename=/u06/app/oradata/TESTDB/cwmlite01.dbf
datafile 4 switched to datafile copy
input datafilecopy recid=3 stamp=541274660 filename=/u06/app/oradata/TESTDB/drsys01.dbf
datafile 5 switched to datafile copy
input datafilecopy recid=4 stamp=541274660 filename=/u06/app/oradata/TESTDB/indx01.dbf
datafile 6 switched to datafile copy
input datafilecopy recid=5 stamp=541274660 filename=/u06/app/oradata/TESTDB/odm01.dbf
datafile 7 switched to datafile copy
input datafilecopy recid=6 stamp=541274660 filename=/u06/app/oradata/TESTDB/tools01.dbf
datafile 8 switched to datafile copy
input datafilecopy recid=7 stamp=541274660 filename=/u06/app/oradata/TESTDB/users01.dbf
datafile 9 switched to datafile copy
input datafilecopy recid=8 stamp=541274660 filename=/u06/app/oradata/TESTDB/xdb01.dbf
datafile 10 switched to datafile copy
input datafilecopy recid=9 stamp=541274660 filename=/u06/app/oradata/TESTDB/example01.dbf
datafile 11 switched to datafile copy
input datafilecopy recid=10 stamp=541274660 filename=/u06/app/oradata/TESTDB/perfstat01.dbf
datafile 12 switched to datafile copy
input datafilecopy recid=11 stamp=541274660 filename=/u06/app/oradata/TESTDB/users02.dbf
 
printing stored script: Memory Script
{
   set until scn  14757706;
   recover
   clone database
    delete archivelog
   ;
}
executing script: Memory Script
 
executing command: SET until clause
 
Starting recover at 03-NOV-04
 
starting media recovery
 
channel ch1: starting archive log restore to default destination
channel ch1: restoring archive log
archive log thread=1 sequence=151
channel ch1: restored backup piece 1
piece handle=/orabackup/ORA920/backup_DB_ORA920_S_17_P_17_T_541269412 tag=TAG20041103T163651 params=NULL
channel ch1: restore complete
archive log filename=/u06/app/oradata/TESTDB/archive/arch_t1_s151.dbf thread=1 sequence=151
channel clone_default: deleting archive log(s)
archive log filename=/u06/app/oradata/TESTDB/archive/arch_t1_s151.dbf recid=1 stamp=541274663
media recovery complete
Finished recover at 03-NOV-04
 
printing stored script: Memory Script
{
   shutdown clone;
   startup clone nomount ;
}
executing script: Memory Script
 
database dismounted
Oracle instance shut down
 
connected to auxiliary database (not started)
Oracle instance started
 
Total System Global Area     252777660 bytes
 
Fixed Size                      451772 bytes
Variable Size                218103808 bytes
Database Buffers              33554432 bytes
Redo Buffers                    667648 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TESTDB" RESETLOGS ARCHIVELOG
  MAXLOGFILES     32
  MAXLOGMEMBERS      5
  MAXDATAFILES      600
  MAXINSTANCES    10
  MAXLOGHISTORY     1134
 LOGFILE
  GROUP  1 ( '/u03/app/oradata/TESTDB/redo_g01a.log', '/u04/app/oradata/TESTDB/redo_g01b.log', '/u05/app/oradata/TESTDB/redo_g01c.log' ) SIZE  104857600
  REUSE,
  GROUP  2 ( '/u03/app/oradata/TESTDB/redo_g02a.log', '/u04/app/oradata/TESTDB/redo_g02b.log', '/u05/app/oradata/TESTDB/redo_g02c.log' ) SIZE  104857600
  REUSE,
  GROUP  3 ( '/u03/app/oradata/TESTDB/redo_g03a.log', '/u04/app/oradata/TESTDB/redo_g03b.log', '/u05/app/oradata/TESTDB/redo_g03c.log' ) SIZE  104857600
  REUSE
 DATAFILE
  '/u06/app/oradata/TESTDB/system01.dbf'
 CHARACTER SET WE8ISO8859P1
 
 
printing stored script: Memory Script
{
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/undotbs1_01.dbf";
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/cwmlite01.dbf";
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/drsys01.dbf";
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/indx01.dbf";
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/odm01.dbf";
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/tools01.dbf";
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/users01.dbf";
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/xdb01.dbf";
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/example01.dbf";
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/perfstat01.dbf";
   catalog clone datafilecopy  "/u06/app/oradata/TESTDB/users02.dbf";
   switch clone datafile all;
}
executing script: Memory Script
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/undotbs1_01.dbf recid=1 stamp=541274721
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/cwmlite01.dbf recid=2 stamp=541274721
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/drsys01.dbf recid=3 stamp=541274721
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/indx01.dbf recid=4 stamp=541274721
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/odm01.dbf recid=5 stamp=541274721
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/tools01.dbf recid=6 stamp=541274721
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/users01.dbf recid=7 stamp=541274721
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/xdb01.dbf recid=8 stamp=541274721
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/example01.dbf recid=9 stamp=541274721
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/perfstat01.dbf recid=10 stamp=541274721
 
cataloged datafile copy
datafile copy filename=/u06/app/oradata/TESTDB/users02.dbf recid=11 stamp=541274721
 
datafile 2 switched to datafile copy
input datafilecopy recid=1 stamp=541274721 filename=/u06/app/oradata/TESTDB/undotbs1_01.dbf
datafile 3 switched to datafile copy
input datafilecopy recid=2 stamp=541274721 filename=/u06/app/oradata/TESTDB/cwmlite01.dbf
datafile 4 switched to datafile copy
input datafilecopy recid=3 stamp=541274721 filename=/u06/app/oradata/TESTDB/drsys01.dbf
datafile 5 switched to datafile copy
input datafilecopy recid=4 stamp=541274721 filename=/u06/app/oradata/TESTDB/indx01.dbf
datafile 6 switched to datafile copy
input datafilecopy recid=5 stamp=541274721 filename=/u06/app/oradata/TESTDB/odm01.dbf
datafile 7 switched to datafile copy
input datafilecopy recid=6 stamp=541274721 filename=/u06/app/oradata/TESTDB/tools01.dbf
datafile 8 switched to datafile copy
input datafilecopy recid=7 stamp=541274721 filename=/u06/app/oradata/TESTDB/users01.dbf
datafile 9 switched to datafile copy
input datafilecopy recid=8 stamp=541274721 filename=/u06/app/oradata/TESTDB/xdb01.dbf
datafile 10 switched to datafile copy
input datafilecopy recid=9 stamp=541274721 filename=/u06/app/oradata/TESTDB/example01.dbf
datafile 11 switched to datafile copy
input datafilecopy recid=10 stamp=541274721 filename=/u06/app/oradata/TESTDB/perfstat01.dbf
datafile 12 switched to datafile copy
input datafilecopy recid=11 stamp=541274721 filename=/u06/app/oradata/TESTDB/users02.dbf
 
printing stored script: Memory Script
{
   Alter clone database open resetlogs;
}
executing script: Memory Script
 
database opened
Finished Duplicate Db at 03-NOV-04
 
RMAN> exit
  1. Create All tempfiles for Temporary Tablespace

In almost all cases, you will need to create the tempfiles for your temporary tablespace:

$ export ORACLE_SID=TESTDB
 
$ sqlplus "/ as sysdba"
 
SQL> alter tablespace temp add tempfile '/u06/app/oradata/TESTDB/temp01.dbf'
  2  size 524288000 reuse autoextend on next 524288000 maxsize 1500M;
 
Tablespace altered.

 

Wednesday, January 07, 2009

RMAN Enhancements in Oracle Database 10g

Oracle 10g includes many RMAN enhancements making it a more complete tool, inlcuding:
Flash Recovery Area
Incrementally Updated Backups
Fast Incremental Backups
BACKUP for Backupsets and Image Copies
Cataloging Backup Pieces
Improved RMAN Reporting Through V$ Views
Automatic Instance Creation for RMAN TSPITR
Cross-Platform Tablespace Conversion
Enhanced Stored Scripts Commands
Backupset Compression
Restore Preview
Managing Backup Duration and Throttling
Miscellaneous
Disk Topology and Automatic Performance Tuning
Automatic Datafile Creation
Proxy Archived Log Backups
Recovery Through Restlogs
Restore Failover
Channel Failover
Deferred Error Reporting
Flash Recovery AreaThe flash recovery area is a location on the filesystem or on an ASM disk group that holds files related to recovery including:
Multiplexed controlfiles
Multiplexed online redo logs
Archived redo logs
Flashback logs
RMAN disk backups
Files created by RESTORE and RECOVERY commands. Space within the flash recovery area is managed by the database. If there is not enough space to complete an operation obsolete, backed up or redundant files are removed to free up some space.The following example shows the parameters used to configure the flash recovery area:
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/u01/app/oracle/flash_recovery_area';
ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 2G;
ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET = 1440;The flashback technologies are covered in the Flashback New Features and Enhancements in Oracle Database 10g article.
Incrementally Updated BackupsUsing this feature all changes between the SCN of the original image copy and the SCN of the incremental backup are applied to the image copy, winding it forward to make the equivalent of a new database image copy without the overhead of such a backup. The following example shows how this can be used:
RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_backup' UNTIL TIME 'SYSDATE - 7';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_backup' DATABASE;
}The RECOVER COPY... line will not do anything until the script has been running for more than 7 days. The BACKUP INCREMENTAL line will perform a complete backup (level 0) the first day it is run, with all subsequent backups being level 1 incremental backups. After 7 days, the RECOVER COPY... line will start to take effect, merging all incremental backups older than 7 days into the level 0 backup, effectively moving the level 0 backup forward. The effect of this is that you will permanently have a 7 day recovery window with a 7 day old level 0 backup and 6 level 1 incremental backups. Notice that the tag must be used to identify which incremental backups apply to which image copies.If you wanted to keep your image copy as up to date as possible you might do the following:

RUN {
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_backup' DATABASE;
RECOVER COPY OF DATABASE WITH TAG 'incr_backup';
}


In this example the incremental backup is merged into the image copy as soon as it is completed.
Fast Incremental BackupsThere are performance issues associated with incremental backups as the whole of each datafile must be scanned to identify changed blocks. In Oracle 10g it is possible to track changed blocks using a change tracking file. Enabling change tracking does produce a small overhead, but it greatly improves the performance of incremental backups. The current change tracking status can be displayed using the following query:
SELECT status FROM v$block_change_tracking;

Change tracking is enabled using the ALTER DATABASE command:
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING;

By default the change tracking file is created as an Oracle Managed File (OMF) in the location pointed to by the DB_CREATE_FILE_DEST parameter. An alternate location can be specified using the following command:
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING
USING FILE '/u01/oradata/MYSID/rman_change_track.f' REUSE;


The tracking file is created with a minumum size of 10M and grows in 10M increments. It's size is typically 1/30,000 the size of the datablocks to be tracked.Change tracking can be disabled using the following command:
ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;

Renaming or moving a tracking file can be accomplished in the normal way using the ALTER DATABASE RENAME FILE command. If the instance cannot be restarted you can simply disable and re-enable change tracking to create a new file. This method does result in the loss of any current change information.
BACKUP for Backupsets and Image CopiesIn Oracle 10g the BACKUP command has been extended to allow it to initiate backups of image copies in addition to backupsets. As a result the COPY command has been deprecated in favour of this new syntax.

BACKUP AS COPY DATABASE;
BACKUP AS COPY TABLESPACE users;
BACKUP AS COPY DATAFILE 1;


RMAN supports the creation of image copies of datafiles and datafile copies, control files and controlfile copies, archived redo logs, and backup pieces.
Cataloging Backup PiecesIt is now possible to manually catalog a backup piece using the CATALOG commands in RMAN. This allows backup files to be moved to alternate locations or manually archived to tape and brought back for restore operations. In Oracle 9i this functionality was only availabale for controlfile copies, archivelog copies and datafile copies. In addition, there are some shortcuts to allow multiple files to be cataloged using a single command. The following examples give the general idea:

# Catalog specific backup piece.
CATALOG BACKUPPIECE '/backup/MYSID/01dmsbj4_1_1.bcp';
# Catalog all files and the contents of directories which
# begin with the pattern "/backup/MYSID/arch".
CATALOG START WITH '/backup/MYSID/arch';
# Catalog all files in the current recovery area.
CATALOG RECOVERY AREA NOPROMPT;
# Catalog all files in the current recovery area.
# This is an exact synonym of the previous command.
CATALOG DB_RECOVERY_FILE_DEST NOPROMPT;

The NOPROMPT clause supresses user confirmation for all matching files.
Improved RMAN Reporting Through V$ ViewsOracle 10g includes additional V$ views making the reporting of backup operations more transparent.
V$RMAN_OUTPUT - This is an in-memory view of the messages reported by RMAN holding a maximum of 32767 rows. Since this information is not recorded in the controlfile it is lost on instance restart.
V$RMAN_STATUS - This view displays progress and status information for in-progress and complete RMAN jobs. The information for the in-progress jobs is memory only, while the complete job information comes from the controlfile.
V$BACKUP_FILES - This view display information about RMAN image copies, backupsets and archived logs, similar to the information listed by the RMAN commands LIST BACKUP and LIST COPY. This view relies on the DBMS_RCVMAN.SETDATABASE procedure being run to set the database. The V$RMAN_CONFIGURATION view from Oracle 9i is still available in Oracle 10g.
Automatic Instance Creation for RMAN TSPITRIf a tablespace point-in-time recovery (TSPITR) is initiated with no reference to an auxillary instance RMAN now automatically creates an one. The auxillary instance configuration is based on that of the target database. As a result, any channels required for the restore operations must be present in the target database so they are configured correctly in the auxillary instance. The location of the datafiles for the auxillary instance are specified using the AUXILIARY DESTINATION clause shown below.

RECOVER TABLESPACE users
UNTIL LOGSEQ 2400 THREAD 1
AUXILIARY DESTINATION '/u01/oradata/auxdest';


The tablespace is taken offline, restored from a backup, recovered to the specified point-in-time in the auxillary instance and re-imported into the target database. The tablespace in the target database should then be backed up and the tablespace brought back online.

BACKUP TABLESPACE users;
SQL "ALTER TABLESPACE users ONLINE";


On successful completion the auxillary instance will be cleaned up automatically. In the event of errors the auxillary instance is left intact to aid troubleshooting.
Cross-Platform Tablespace ConversionThe CONVERT TABLESPACE allows tablespaces to be transported between platforms with different byte orders. The mechanism for transporting a tablespaces is unchanged, this command merely converts the tablespace to allow the transport to work.The platform of the source and destination platforms can be identified using the V$TRANSPORTABLE_PLATFORM view. The platform of the local server is not listed as no conversion in necessary for a matching platform.

SQL> SELECT platform_name FROM v$transportable_platform;
PLATFORM_NAME

------------------------------------
Solaris[tm] OE (32-bit)
...
...
Microsoft Windows 64-bit for AMD
15 rows selected.The tablespace conversion can take place on either the source or the destination server. The following examples show how the command is used in each case:

# Conversion on a Solaris source host to a Linux destincation file.
CONVERT TABLESPACE my_tablespace
TO PLATFORM 'Linux IA (32-bit)'
FORMAT='/tmp/transport_linux/%U';

# Conversion on a Linux destination host from a Solaris source file.
CONVERT DATAFILE=
'/tmp/transport_solaris/my_ts_file01.dbf',
'/tmp/transport_solaris/my_ts_file02.dbf'
FROM PLATFORM 'Solaris[tm] OE (32-bit)'
DB_FILE_NAME_CONVERT
'/tmp/transport_solaris','/u01/oradata/MYDB';

In the first example the converted files are placed in the directory specified by the FORMAT clause. In the second example the specified datafiles are converted to the local servers platform and placed in the correct directory specified by the DB_FILE_NAME_CONVERT clause.
Enhanced Stored Scripts CommandsScripts can now be defined as global allowing them to be accessed by all databases within the recovery catalog. The syntax for global script manipulation is the same as that for regular scripts with the addition of the GLOBAL clause prior the word SCRIPT. Examples of it's usage are shown below:

CREATE GLOBAL SCRIPT full_backup
{
BACKUP DATABASE PLUS ARCHIVELOG;
DELETE FORCE NOPROMPT OBSOLETE;

}
CREATE GLOBAL SCRIPT full_backup FROM FILE 'full_backup.txt';

RUN { EXECUTE GLOBAL SCRIPT full_backup; }
PRINT GLOBAL SCRIPT full_backup;
LIST GLOBAL SCRIPT NAMES;
LIST ALL SCRIPT NAMES;


# Global and local scripts.
REPLACE GLOBAL SCRIPT full_backup
{
BACKUP DATABASE PLUS ARCHIVELOG;
DELETE FORCE NOPROMPT OBSOLETE;
}

REPLACE GLOBAL SCRIPT full_backup FROM FILE 'full_backup.txt';
DELETE GLOBAL SCRIPT 'full_backup';

Backupset CompressionThe AS COMPRESSED BACKUPSET option of the BACKUP command allows RMAN to perform binary compression of backupsets. The resulting backupsets do not need to be uncompressed during recovery. It is most useful in the following circumstances:
You are performing disk-based backup with limited disk space.
You are performing backups across a network where network bandwidth is limiting.
You are performing backups to tape, CD or DVD where hardware compression is not available. The following examples assume that some persistent parameters are configured in a similar manner to those listed below:

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/backups/MYSID/%d_DB_%u_%s_%p';

The AS COMPRESSED BACKUPSET option can be used explicitly in the backup command:
# Whole database and archivelogs.
BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG;
# Datafiles 1 and 5 only.
BACKUP AS COMPRESSED BACKUPSET DATAFILE 1,5;

Alternatively the option can be defined using the CONFIGURE command:
# Configure compression.
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;

# Whole database and archivelogs.

BACKUP DATABASE PLUS ARCHIVELOG;

Compression requires additional CPU cycles which may affect the performance of the database. For this reason it should not be used for tape backups where hardware compression is available.
Restore PreviewThe PREVIEW option of the RESTORE command allows you to identify the backups required to complete a specific restore operation. The output generated by the command is in the same format as the LIST command. In addition the PREVIEW SUMMARY command can be used to produce a summary report with the same format as the LIST SUMMARY command. The following examples show how these commands are used:
# Preview
RESTORE DATABASE PREVIEW;
RESTORE TABLESPACE users PREVIEW;


# Preview Summary
RESTORE DATABASE PREVIEW SUMMARY;
RESTORE TABLESPACE users PREVIEW SUMMARY;


Managing Backup Duration and ThrottlingThe DURATION clause of the of the BACKUP command restricts the total time available for a backup to complete. At the end of the time window backup is interrupted with any incomplete backupsets discarded. All complete backupsets aer kept and used for future restore operations. The following examples show how it is used:
BACKUP DURATION 2:00 TABLESPACE users;
BACKUP DURATION 5:00 DATABASE PLUS ARCHIVELOGS;

Miscellaneous
Disk Topology and Automatic Performance Tuning - RMAN includes a new disk topology API allowing it to work with more platforms and file types. The information from this API allows RMAN to automatically tune some parameters related to multiplexing and disk buffers, decreasing the need to human intervention.
Automatic Datafile Creation - RMAN will automatically create missing datafiles in two circumstances. First, when the backup controlfile contains a reference to a datafile, but no backup of the datafile is present. Second, when a backup of the datafile is present, but there is no reference in the controlfile as it was not backed up after the datafile addition.
Proxy Archived Log Backups - During a proxy backup the media manager takes over full control of the backup process. RMAN is now able to backup and restore proxy copies of archived redo logs if a suitable media manager is used. If a suitable media manager is not available PROXY clause is ignored and a regular backup is performed. Using the PROXY ONLY results in an error of a proxy backup cannot be performed.
Restore Failover - RMAN now allows the recovery process to preceed from one incarnation through to another. The contents of the online redo logs are archived before being cleared when an OPEN RESTLOGS operation is issued. As a result it is no longer necessary to create a new backup after OPEN RESTLOGS operations.
Recovery Through Restlogs - When a backup file contains corrupt blocks or is inaccesible during restore operations (RECOVER, BLOCKRECOVER, and FLASHBACK DATABASE) RMAN automatically looks for another copy of the file. If one is not available RMAN will use older versions of the file if available. Only if a suitable copy of the file cannot be found will an error be produced. Successful failover operations result in an associated output message.
Channel Failover - When multiple channels are available for the same device type retriable errors in a backup step will automatically be retried on another channel. Retriable errors are usually associated with media managers failing to access tapes or instance failures in RAC environments.
Deferred Error Reporting - In addition to error messages during the job execution, the error stack at the end of the command execution now displays errors for all failed steps, making identification of failed step easier.