oracle rman

22
General RMAN Information : What is RMAN and How to configure it ? Why to use RMAN ? How RMAN works ? What O/S and oracle user privilege required to use RMAN ? RMAN terminology Q.What is RMAN and How to configure it ? A.RMAN is an Oracle Database client that performs backup and recovery tasks on your databases and automates administration of your backup strategies. It greatly simplifies the dba jobs by managing the production database's backing up, restoring, and recovering database files. This tool integrates with sessions running on an Oracle database to perform a range of backup and recovery activities, including maintaining an RMAN repository of historical data about backups. There is no additional installation required for this tool. Its by default get installed with the oracle database installation. The RMAN environment consists of the utilities and databases that play a role in backing up your data.You can access RMAN through the command line or through Oracle Enterprise Manager. Q.Why to use RMAN ? A.RMAN gives you access to several backup and recovery techniques and features not available with user-managed backup and recovery. The most noteworthy are the following: -- Automatic specification of files to include in a backup : Establishes the name and locations of all files to be backed up. -- Maintain backup repository : Backups are recorded in the control file, which is the main repository of RMAN metadata. Additionally, you can store this metadata in a recovery catalog, -- Incremental backups : An incremental backup stores only blocks changed since a previous backup. Thus, they provide more compact backups and faster recovery, thereby reducing the need to apply redo during datafile media recovery. -- Unused block compression : In unused block compression, RMAN can skip data blocks that have never been used -- Block media recovery : You an repair a datafile with only a small number of corrupt data blocks without taking it offline or restoring it from backup. -- Binary compression : A binary compression mechanism integrated into Oracle Database reduces the size of backups. -- Encrypted backups : RMAN uses backup encryption capabilities integrated into Oracle Database to store backup sets in an encrypted format. 1

Upload: malru

Post on 21-Jul-2016

27 views

Category:

Documents


3 download

DESCRIPTION

RMAN concepts

TRANSCRIPT

Page 1: Oracle Rman

General RMAN Information :

What is RMAN and How to configure it ?Why to use RMAN ?How RMAN works ?What O/S and oracle user privilege required to use RMAN ? RMAN terminology

Q.What is RMAN and How to configure it ?A.RMAN is an Oracle Database client that performs backup and recovery tasks on your databases and automates administration of your backup strategies. It greatly simplifies the dba jobs by managing the production database's backing up, restoring, and recovering database files.

 This tool integrates with sessions running on an Oracle database to perform a range of backup and recovery activities, including maintaining an RMAN repository of historical data about backups. There is no additional installation required for this tool. Its by default get installed with the oracle database installation. The RMAN environment consists of the utilities and databases that play a role in backing up your data.You can access RMAN through the command line or through Oracle Enterprise Manager.

Q.Why to use RMAN ?A.RMAN gives you access to several backup and recovery techniques and features not available with user-managed backup and recovery. The most noteworthy are the following:

-- Automatic specification of files to include in a backup :  Establishes the name and locations of all files to be backed up. 

-- Maintain backup repository :  Backups are recorded in the control file, which is the main repository of RMAN metadata.  Additionally, you can store this metadata in a recovery catalog,

-- Incremental backups  : An incremental backup stores only blocks changed since a previous backup. Thus, they provide more compact backups and faster recovery, thereby reducing the need to apply redo during datafile media recovery.

-- Unused block compression  :  In unused block compression, RMAN can skip data blocks that have never been used

-- Block media recovery : You an repair a datafile with only a small number of corrupt data blocks without taking it offline or restoring it from backup.

-- Binary compression : A binary compression mechanism integrated into Oracle Database reduces the size of backups.

-- Encrypted backups : RMAN uses backup encryption capabilities integrated into Oracle Database to store backup sets in an encrypted format.

-- Corrupt block detection :  RMAN checks for the block corruption before taking its backup.

 

Q.How RMAN works ?A.RMAN backup and recovery operation for a target database are managed by RMAN client. RMAN uses the target database control file to gather metadata about the target database and to store information about its own operations. The RMAN client itself does not perform backup, restore, or recovery operations.

1

Page 2: Oracle Rman

When you connect the RMAN client to a target database, RMAN allocates server sessions on the target instance and directs them to perform the operations.The work of backup and recovery is performed by server sessions running on the target database. A channel establishes a connection from the RMAN client to a target or auxiliary database instance by starting a server session on the instance.The channel reads data into memory, processes it, and writes it to the output device.

When you take a database backup using RMAN, you need to connect to the target database using RMAN Client.The RMAN client can use Oracle Net to connect to a target database, so it can be located on any host that is connected to the target host through Oracle Net. For backup you need to allocate explicit or implicit channel to the target database. An RMAN channel represents one stream of data to a device, and corresponds to one database server session. This session dynamically collect information of the files from the target database control file before taking the backup or while restoring.

  For example If you give ' Backup database ' from RMAN, it will first get all the datafiles information from the controlfile. Then it will divide all the datafiles among the allocated channels. ( roughly equal size of work as per the datafile size ). Then it takes the backup in 2 steps. In the first step the channel will read all the Blocks of the entire datafile to find out all the formatted blocks to backup. Note : RMAN do not take backup of the un formatted blocks. In the second step it take backup of the formatted blocks. This is the best advantage of using RMAN as it only take backup of the required blocks. Lets say in a datafile of 100 MB size, there may be only 10 MB of use full data and rest 90 MB is free then RMAN will only take backup of those 10 MB.

Q.What O/S and  oracle user privilege required to use RMAN ? A.RMAN always connect to the target or auxiliary database using the SYSDBA privilege. In fact the SYSDBA keywords are implied and cannot be explicitly specified. Its connections to a database are specified and authenticated in the same way as SQL*Plus connections to a database.

The O/S user should be part of the DBA group . For remote connection it needs the password file Authentication.Target database should have the initialization parameter REMOTE_LOGIN_PASSWORDFILE set to EXCLUSIVE or SHARED.

Q.RMAN terminology  :

A target database : An Oracle database to which RMAN is connected with the TARGET keyword. A target database is a database on which RMAN is performing backup and recovery operations. RMAN always maintains metadata about its operations on a database in the control file of the database.

A recovery Catalog : A separate database schema used to record RMAN activity against one or more target databases. A recovery catalog preserves RMAN repository metadata if the control file is lost, making it much easier to restore and recover following the loss of the control file. The database may overwrite older records in the control file, but RMAN maintains records forever in the catalog unless deleted by the user.

Backup sets : RMAN can store backup data in a logical structure called a backup set, which is the smallest unit of an RMAN backup. One backup set contains one or more datafiles a section of datafile or archivelogs.

Backup Piece : A backup set contains one or more binary files in an RMAN-specific format. This file is known as a backup piece. Each backup piece is a single output file. The size of a backup piece can be restricted; if the size is not restricted, the backup set will comprise one backup piece. Backup piece size should be restricted to no larger than the maximum file size that your filesystem will support.

Image copies : An image copy is a copy of a single file (datafile, archivelog, or controlfile). It is very similar to an O/S copy of the file. It is not a backupset or a backup piece. No compression is performed.

Snapshot Controlfile : When RMAN needs to resynchronize from a read-consistent version of the control 2

Page 3: Oracle Rman

file, it creates a temporary snapshot control file. The default name for the snapshot control file is port-specific.

Database Incarnation : Whenever you perform incomplete recovery or perform recovery using a backup control file, you must reset the online redo logs when you open the database. The new version of the reset database is called a new incarnation. The reset database command directs RMAN to create a new database incarnation record in the recovery catalog. This new incarnation record indicates the current incarnation.

RMAN Configuration :

What is RMAN Configuration and how to Configure it ?How to check RMAN Configuration ?How to Reset the default Configuration ?

Q.What is RMAN Configuration and how to Configure it ?A.The RMAN backup and recovery environment is preconfigured for each target database. The configuration is persistent and applies to all subsequent operations on this target database, even if you exit and restart RMAN. RMAN configured settings can specify backup devices, configure a connection to a backup device , policies affecting backup strategy, encryption algorithm, snap shot controlfile loaion  and others.

By default there are few default configuration are set when you login to RMAN. You can customize them as per your requirement. Any time you can check the current setting by using the "Show all " command. CONFIGURE command is used to create persistent settings in the RMAN environment, which apply to all subsequent operations, even if you exit and restart RMAN.For details of the Configuration kindly refer Note <>

Q.How to check RMAN Configuration ?

RMAN>Show all;

 

Q.How to Reset to default Configuration ?

A.To reset the default configuration setting use

Connect to the target database from sqlplus and run

SQL> connect <sys/passwd as sysdba>@target_database;  SQL> execute dbms_backup_restore.resetConfig; 

RMAN Catalog Database

What is Catalog database and How to Configure it ?How Many catalog database I can have ?Is this mandetory to use catalog database ? What is the advantage of catalog database ?What is the difference between catalog database and catalog schema ?Catalog database compatibility matrix with the target database ?What happen if catalog database lost ?

3

Page 4: Oracle Rman

Q. What is Catalog database and How to Configure it ?A. This is a separate database which contains catalog schema. You can use the same target database as the catalog database but its not at all recommended. For more details on Recovery catalog kindly refer the Note 452529.1: Recovery catalog for RMAN backup

Q. How Many catalog database I can have ?A.  You can have multiple catalog database for the same target database . But at a time you can connect to only 1 catalog database via RMAN. Its not recommended to have multiple catalog database.

Q. Is this mandatory to use catalog database ?A.  No ! its a optional one.

Q. What is the advantage of catalog database ?A.  Catalog database is a secondary storage of backup metadata. Its very useful in case you lost the current controlfile, as all the backup information are there in the catalog schema. Secondly from contolfile the older backup information are aged out depending upon the control_file_record_keep_time. RMAN catalog database mainten the history of data. Kindly refer the note <> for more details on relation between  retention policy and control_File_record_keep_time.

Q. What is the difference between catalog database & catalog schema ?A.  Catalog database is like any other database which contains the RMAN catalog user's schema.

Q. Catalog database compatibility matrix with the target database ?A.  refer Note 73431.1 : RMAN Compatibility Matrix

Q. What happen if catalog database lost ? A.  Since catalog database is a option one there is no direct effect  of loss of catalog  database. Create  a new catalog database and register the target database with the newly createdcatalog one. All the backup information from the target database current controlfile will be updated to the catalog schema. If any backup information which is aged out from the target database then you need to manually catalog those backup pieces.

RMAN backup :

What are the database files that RMAN can backup ? What are the database files that RMAN can not backup ? Can I have archivelogs and datafile backup in a single backupset ?Can I have datafiles and contolfile backup in a single backup set?Can I regulate the size of backup piece and backupset ?What is the difference between backup set backup and Image copy backup ?What is RMAN consistent backup and Inconsistent backup ?Can I take RMAN backup when the database is Down ? Do I need to place the database in begin backup mode while taking RMAN inconsistent backup ? Can I compress RMAN backups ?Can I encrypt RMAN backup ?

Q. What are the database file's that RMAN can backup ?A. RMAN can backup  Controlfile , Datafiles , Archive logs , standby database controfile, Spfile

Q. What are the  database file's that RMAN can not backup ? A.  RMAN can not take backup of the pfile, Redo logs , network configuration files, password files, external  tables and the contents of the Oracle home files

Q. Can I have archivelogs and datafile backup in a single backupset ?A.  No . we can not put datafiles and archive logs in the same backupset.

4

Page 5: Oracle Rman

Q. Can I have datafiles and contolfile backup in a single backup set ? A. Yes . If the controlfile autobackup is not ON then RMAN takes backup of controlfile along with the datafile 1, whenever you take backup of the database or System tablespace. Kindly refer ( *** create a note for controfile auto backup ) 

Q. Can I regulate the size of backup piece and backupset ?A. Yes ! You can set max size of the backupset as well as the backup piece. By default one RMAN channel  creates a single backupset with one backup piece in it. You can use the MAXPIECESIZE channel parameter to set limits on the size of backup pieces. You can also use the MAXSETSIZE parameter on the BACKUP and CONFIGURE commands to set a limit for the size of backup sets.

Q. What is the difference between backup set backup and Image copy backup ?A :  A backup set is an RMAN-specific proprietary format, whereas an image copy is a bit-for-bit copy of a file. By default,RMAN creates backup sets

Q. What is RMAN consistent backup and inconsistent backup ?A. A consistent backup occurs when the database is in a consistent state. That means backup of the database taken after a shutdown immediate , shutdown normal or shutdown transactional. If the database is shutdown with  abort option then its not a consistent backup. A backup when when the database is Up and running is called an inconsistent backup. When a database is restored from an inconsistent backup, Oracle must perform media recovery before the database can beopened, applying any pending changes from the redo logs. You can not take inconsistent backup when the database is in NoArchivelog mode.

Q. Can I take RMAN backup when the database is Down ?A. No ! You can take RMAN backup only when the target database is Open or in Mount stage. Its because RMAN keep the backup metadata in controfile . Only in open or mount mode controlfile is accessible.

Q. Do I need to place the database in begin backup mode while taking RMAN inconsistent backup ?A. RMAN does not require extra logging or backup mode because it knows the format of data blocks. RMAN is guaranteed not to back up fractured blocks.No extra redo is generated during RMAN backup.

Q. Can I compress RMAN backups ?A. RMAN supports binary compression of backup sets. The supported algorithms are BZIP2 (default) and ZLIB.  Kindly refer Note 563427.1 for more details about different type of compressions. Its not recommend to compress  the RMAN backup using any other OS or third party utility.

Note : RMAN compressed backup with BZIP2 provides great compression but is CPU intensive. Using ZLIB compression requires the Oracle Database 11g Advanced Compression Option and is only supported with an 11g database. The feature is not backward compatible with 10g databases.

Q. Can I encrypt RMAN backup ?A. RMAN supports backup encryption for backup sets. You can use wallet-based transparent encryption, password-based encryption, or both. You can use the CONFIGURE ENCRYPTION command to configure persistent transparent encryption. Use the SET ENCRYPTION, command at the RMAN session level to specify password-based encryption.

8.13 How to specify backup destination ?

9. Can RMAN take backup to Tape ?

Yes ! you can use RMAN for the tape backup. But RMAN can not able to write directly to tape. You need to have third party Media Management Software installed. Oracle has published an API specification which Media Management Vendor's who are members of Oracle's Backup Solutions Partner program have access

5

Page 6: Oracle Rman

to. Media Management Vendors (MMVs) then write an interface library which the Oracle server uses to write and read to and from tape.

9.1 Where can I get the list of supported Third party Media Management Software for tape backup ?

RMAN should not be used with that Media Manager until the MMV has certified that their software works with RMan. Either contact your Media Manager, or check the RMan home page for updates on which MMVs have certified their products on which platforms:

http://www.oracle.com/technology/deploy/availability/htdocs/bsp.htm

Starting from oracle 10g R2 oracle has its Own Media management software for the database backup to tape called OSB.

9.2 How RMAN Interact with Media manager ?

Before performing backup or restore to a media manager, you must allocate one or more channels or configure default channels for use with the media manager to handle the communication with the media manager. RMAN does not issue specific commands to load, label, or unload tapes. When backing up, RMAN gives the media manager a stream of bytes and associates a unique name with this stream. When RMAN needs to restore the backup, it asks the media manager to retrieve the byte stream. All details of how and where that stream is stored are handled entirely by the media manager.

9.3 What is Proxy copy backup to tape ?

Proxy copy is functionality, supported by few media manager  in which they handle the entire data movement between datafiles and the backup devices. Such products may use technologies such as high-speed connections between storage and media subsystems to reduce load on the primary database server. RMAN provides a list of files requiring backup or restore to the media manager, which in turn makes all decisions regarding how and when to move the data.

9.4 What is Oracle Secure backup ?

Oracle Secure Backup is a media manager provided by oracle that provides reliable and secure data protection through file system backup to tape. All major tape drives and tape libraries in SAN, Gigabit Ethernet, and SCSI environments are supported.

6

Page 7: Oracle Rman

Overview of the RMAN Environment

Installed with the database, Recovery Manager (RMAN) is an Oracle database client which performs backup and recovery tasks on your databases and automates administration of your backup strategies. It greatly simplifies backing up, restoring, and recovering the database.

The RMAN environment consists of the utilities and databases that play a role in backing up your data. At a minimum, the environment for RMAN must include the following: 

The target database.  This is the database to be backed up by RMAN. The RMAN client is a command-line-oriented database client, much like SQL*Plus, with its own

command syntax. From the RMAN client you can issue RMAN commands and some SQL statements to perform and report on backup and recovery operations.

Some environments will also use these optional components:

A flash recovery area:  a disk location in which the database can store and manage files related to backup and recovery.

Media management software:  software provided by media manager vendors which is required for RMAN to interface with backup devices such as tape drives.

A recovery catalog database:  a separate database schema used to record RMAN activity against one or more target databases.

Deciding Whether to Use a Flash Recovery Area (FRA)

It is recommended that you take advantage of the FRA to store as many backup and recovery-related files as as possible, including disk backups and archived redo logs.

Some features of Oracle database backup and recovery, such as Oracle Flashback Database and guaranteed restore points, require the use of an FRA. However, having an FRA for use by these features does not force you to use it to store all recovery-related files.

Even when its use is not required, however, the FRA offers a number of advantages over other on-disk backup storage methods. Backups moved to tape from the flash recovery area (via RMAN and media manager) are retained on disk until space is needed for other required files, reducing the need to restore backups from tape. At the same time, obsolete files no longer needed to meet your recoverability goals and files backed up to tape become eligible for deletion and are deleted when space is needed. These deletions are managed by Oracle when space is required.  The DBA no longer has to manually delete old backups, and, it is less likely that a DBA accidentally deletes redundancy set files.  Note that if backups written to the FRA are not copied via RMAN and media manager to tape, the automatic deletion of obsolete backups does not occur and pre-Oracle10g cleanup methods are required.

Knowledgebase Article Reference:

Note:305817.1  FAQ - Flash Recovery Area feature of 10G

Deciding Whether to use a Recovery Catalog

RMAN maintains metadata about the target database and its backup and recovery operations in the RMAN repository. Among other things, RMAN stores information about its own configuration settings, the target database schema, archived redo logs, and all backup files on disk or tape. RMAN's LIST, REPORT, and

7

Page 8: Oracle Rman

SHOW commands display RMAN repository information.

The primary store for RMAN repository data is always the control file of the target database. The CONTROL_FILE_RECORD_KEEP_TIME initialization parameter controls how long backup records are kept in the control file before those records are re-used to hold information about more recent backups.

Another copy of the RMAN repository data can also be saved in the recovery catalog.

Using a recovery catalog preserves RMAN repository information if the control file is lost, making it much easier to restore and recover following the loss of the control file. (A backup control file may not contain complete information about recent available backups.) The recovery catalog can also store a much more extensive history of your backups than the control file, due to limits on the number of control file records.

In addition to RMAN repository records, the recovery catalog can also hold RMAN stored scripts, sequences of RMAN commands for common backup tasks. Centralized storage of scripts in recovery catalog can be more convenient than working with command files.

Except for stored scripts, all of RMAN's features work equally well with or without a recovery catalog.

Oracle10g Documentation References:

Oracle Database Backup and Recovery Advanced User's Guide Guide - more information about the recovery   catalog

Oracle Database Backup and Recovery Reference - CREATE CATALOG command syntax

 

Starting and Exiting RMAN

The RMAN client is started by issuing the rman command at the command prompt of your operating system. RMAN must connect to a target database (with SYSDBA privileges) to perform backup and recovery tasks. RMAN can also connect to a recovery catalog database if you are using one. Specify target and recovery catalog databases using command line options or using the CONNECT command.

This command illustrates connecting RMAN to a target database and a recovery catalog at startup:

% rman TARGET / CATALOG cat_usr/pwd@cat_str

Connect to a target database without using a recovery catalog:

% rman TARGET SYS/pwd@target_str

Starting RMAN without connecting to a database:

% rman

Once started, RMAN displays an "RMAN>" prompt for your commands.

 

8

Page 9: Oracle Rman

 

Configuring Persistent Settings for the RMAN Environment

You can use the RMAN CONFIGURE command to create persistent settings in the RMAN environment, which apply to all subsequent operations, even if you exit and restart RMAN. These configured settings can specify disk and SBT channel behavior, backup destinations, policies affecting backup strategy, and others.

This command shows all configurable settings:

RMAN> SHOW ALL;

Knowledgebase Article:

Note 305565.1 Persistent Controlfile Configurations for RMAN in 9i and 10g

Oracle10g Documentation Reference

Oracle Database Backup and Recovery Basics - more information   about configuration settings.

 

Backing up the Controlfile and Spfile

The control file can be automatically backed up after each RMAN backup and database structure change as a way to protect the RMAN repository.  If an spfile is being used, it is also backed up.  When using RMAN without a recovery catalog, it is recommended that the controlfile autobackup be set to ON.  The following command configures RMAN to create these control file autobackups:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

By default, RMAN automatically generates names for control file autobackups and stores them in the FRA if defined. The following command configures RMAN to write control file autobackups to the /mybackupdir directory:

 

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT       FOR DEVICE TYPE DISK TO '/mybackupdir/cf%F';

The %F element of the format string combines the DBID, day, month, year, and sequence number to generate a unique filename. %F must be included in any control file autobackup format.

 

You can back up the control file when the database is mounted or open. RMAN uses a snapshot control file to ensure a read-consistent version. If CONFIGURE CONTROLFILE AUTOBACKUP is ON (by default it is OFF), then RMAN automatically backs up the control file and server parameter file after every backup and after database structural changes. The controlfile autobackup contains metadata about the previous backup, which is crucial for disaster recovery.  Configuring controlfile autobackup on is recommended and is the only way RMAN can restore a controlfile backup if all controlfiles are lost and there is no recovery catalog

9

Page 10: Oracle Rman

in use. 

If the autobackup feature is not set, then you must manually back up the control file in one of the following ways:

Run BACKUP CURRENT CONTROLFILE Include a backup of the control file within any backup by using the INCLUDE CURRENT

CONTROLFILE option of the BACKUP command

Back up datafile 1, because RMAN automatically includes the control file and SPFILE in backups of datafile 1 when the controlfile autobackup is set to OFF.

A manual backup of the control file is not the same as a control file autobackup. In manual backups, only RMAN repository data for backups within the current RMAN session is in the control file backup, and a manually backed-up control file cannot be automatically restored. 

Oracle10g Documentation Reference:

Oracle Database Backup and Recovery Advanced User's Guide - more information   about control file autobackups

 

Backing up Database Files

Use the RMAN BACKUP command to back up files. You can configure default devices and channels in advance.  The BACKUP command backs up your data to the configured default device and channels for the type of backup requested.

If you specify BACKUP AS COPY, then RMAN copies the files as image copies, bit-for-bit copies of database files created on disk. These are identical to copies of the same files that you can create with operating system commands like cp on Unix or COPY on Windows.  However, using BACKUP AS COPY will be recorded in the RMAN repository and RMAN can use them in restore operations. Image copies cannot be created on tape.

This command creates image copy backups of all datafiles in the database:

RMAN> BACKUP AS COPY DATABASE;

 

If you specify BACKUP AS BACKUPSET, then RMAN stores its backups in backup sets. A backup set, consisting of one or more backup pieces, contains the physical file data being backed up.  This backupset is written in a format that only RMAN can access. Only RMAN can create and restore backup sets. Backup sets can be written to disk or tape, and they are the only type of backup which RMAN can use to write backups to tape.

The following command creates a backup of the database and archived logs on tape, in backup set format, using the configured channels:

 

RMAN> BACKUP DEVICE TYPE sbt DATABASE PLUS ARCHIVELOG;

 10

Page 11: Oracle Rman

Note: Backing up datafiles as backup sets on disk can save disk space and time because RMAN will skip backing up some unused datafile blocks. Backup sets, once written on disk, can be moved to tape with the BACKUP BACKUPSET command. See the description of unused block compression in Oracle Database Backup and Recovery Reference for details.

Backing Up Individual Files

You can back up individual tablespaces, datafiles and control files, server parameter files, and backup sets with various options, as in these examples:

RMAN> BACKUP ARCHIVELOG from time 'sysdate-2';

RMAN> BACKUP TABLESPACE system, users, tools;

RMAN> BACKUP AS BACKUPSET DATAFILE 'ORACLE_HOME/oradata/trgt/users01.dbf', 'ORACLE_HOME/oradata/trg/tools01.dbf';

RMAN> BACKUP DATAFILE 1,3,5;

RMAN> BACKUP CURRENT CONTROLFILE TO '/backup/curr_cf.copy';

RMAN> BACKUP SPFILE;

RMAN> BACKUP BACKUPSET ALL;

Backup Options

Here are some often-used BACKUP command options:

Parameter                                Example                        Explanation FORMAT                               FORMAT'/tmp/%U'     Specifies a location and name for backup pieces and copies. You must use substitution variables to generate unique filenames.

Parameter                        Example                        Explanation TAG                                TAG 'monday_bak'       Specifies a user-defined string as a label for the backup. If you do not specify a tag, then RMAN assigns a default tag with the date and time.

The following BACKUP commands illustrate these options:

RMAN> BACKUP FORMAT='AL_%d/%t/%s/%p' ARCHIVELOG LIKE '%arc_dest%';

RMAN> BACKUP TAG 'weekly_full_db_bkup' DATABASE MAXSETSIZE 10M;

RMAN> BACKUP COPIES 2 DEVICE TYPE sbt BACKUPSET ALL;

Incremental Backups :

If you specify BACKUP INCREMENTAL, RMAN will create incremental backups of your database. Incremental backups capture on a block-by-block basis changes in your database since a previous incremental backup. The starting point for an incremental backup strategy is a level 0 incremental backup, which backs up all

11

Page 12: Oracle Rman

blocks in the database. Level 1 incremental backups, taken at regular intervals, contain only changed blocks since a previous incremental backup. These can be cumulative (including all blocks changed since the most recent level 0 backup) or differential (including only blocks changed since the most recent incremental backup, whether it is level 0 or level 1).

Incremental backups are generally smaller and faster to create than full database backups. Recovery from an incremental backup is faster than recovery using redo logs alone. During a restore from incremental backup, the level 0 backup is used as the starting point, then changed blocks are updated based on level 1 backups where possible to avoid re-applying changes from redo one at a time. Recovering with incremental backups requires no additional effort on your part. If incremental backups are available, RMAN will use them during recovery.

Enterprise Edition includes RMAN's change tracking feature for incremental backups which improves incremental backup performance by recording changed blocks in each datafile in a change tracking file. If change tracking is enabled, RMAN uses the change tracking file to identify changed blocks for incremental backup, thus avoiding the need to scan every block in the datafile. 

Knowledgebase Article Reference:

Note 262853.1 10G RMAN Fast Incremental Backups

Incrementally Updated Backups:

RMAN's incrementally updated backups feature allows for a more efficient incremental backup routine. Changes from level 1 backups can be used to roll forward an image copy level 0 incremental backup, so that it includes all changes as of the SCN at which the level 1 incremental backup was created. Recovery using the updated level 0 incremental backup is faster, because all changes from the level 1 incremental backup have already been applied.

Oracle10g Documentation References:

Oracle Database Backup and Recovery Basics - more details and examples for incremental backups and incrementally updated backups.

 Oracle Database Backup and Recovery Reference - complete BACKUP command syntax.

 

Backing Up Archived Redo Logs

Archived redo logs are the key to successful media recovery. Back them up regularly. You can back up logs with BACKUP ARCHIVELOG, or back up logs while backing up datafiles and control files by specifying BACKUP ... PLUS ARCHIVELOG.

To back up archived redo logs, use the BACKUP ARCHIVELOG command at the RMAN prompt. This example uses a configured disk or sbt channel to back up one copy of each log sequence number for all archived redo logs:

 

RMAN> BACKUP ARCHIVELOG ALL;

Even if your redo logs are being archived to multiple destinations and you use RMAN to back up archived

12

Page 13: Oracle Rman

redo logs, RMAN selects only one copy of the archived redo log file to include in the backup set. (Since logs with the same log sequence number are identical, there is no need to include more than one copy.)

You can also specify a range of archived redo logs by time, SCN, or log sequence number, as in the following example:

 

RMAN> BACKUP ARCHIVELOG       FROM TIME 'SYSDATE-30' UNTIL TIME 'SYSDATE-7';

You can specify the DELETE INPUT or DELETE ALL INPUT clauses for the BACKUP ARCHIVELOG command to delete archived logs after they are backed up, eliminating the separate step of manually deleting the archived redo logs. With DELETE INPUT, RMAN only deletes the specific copy of the archived redo log chosen for the backup set. With DELETE ALL INPUT, RMAN will delete each backed-up archived redo log file from all log archiving destinations. 

Oracle10g Documentation References:

Oracle Database Backup and Recovery Basics - more details regarding archived log backups  Oracle Database Backup and Recovery Reference - complete BACKUP and archivelogRecordSpecifier command syntax

 

Restoring and Recovering Database Files

Use the RESTORE and RECOVER commands for RMAN restore and recovery of physical database files. Restoring datafiles is retrieving them from backups as needed for a recovery operation. Recovery is the application of changes from redo logs and incremental backups to a restored datafile, to bring the datafile to a desired SCN (point in time) or to current time. 

Recovering the Whole Database :

Use the RESTORE DATABASE and RECOVER DATABASE commands on the whole database. For example:

RMAN> STARTUP FORCE MOUNT;       RESTORE DATABASE;       RECOVER DATABASE;       ALTER DATABASE OPEN;

Note that the database must not be open when restoring or recovering the entire database.

Recovering Current Tablespaces :

Use the RESTORE TABLESPACE and RECOVER TABLESPACE commands on individual tablespaces when the database is open. Take the tablespace that needs recovery offline, restore and then recover the tablespace, and bring the recovered tablespace online. The following steps recover the users tablespace:

RMAN> SQL 'ALTER TABLESPACE users OFFLINE';       RESTORE TABLESPACE users;       RECOVER TABLESPACE users;       SQL 'ALTER TABLESPACE users ONLINE;

13

Page 14: Oracle Rman

Recovering Current Datafiles :

Use the RESTORE DATAFILE and RECOVER DATAFILE commands on individual current datafiles when the database open. Take the datafile that needs recovery offline, restored recover the datafile, and bring the datafile online. For example, to restore and recover datafile 7:

RMAN> SQL 'ALTER DATABASE DATAFILE 7 OFFLINE';       RESTORE DATAFILE 7;      RECOVER DATAFILE 7;       SQL 'ALTER DATABASE DATAFILE 7 ONLINE';

Recovering Individual Data Blocks :

RMAN can recover individual corrupted datafile blocks. When RMAN performs a complete scan of a file for a backup, any corrupted blocks are listed in V$DATABASE_BLOCK_CORRUPTION. Corruption is usually reported in alert logs, trace files or results of SQL queries. Use BLOCKRECOVER to repair all corrupted blocks:

 

RMAN> BLOCKRECOVER CORRUPTION LIST;

You can also recover individual blocks, as shown in this example:

 

RMAN> BLOCKRECOVER DATAFILE 7 BLOCK 233, 235 DATAFILE 4 BLOCK 101;

Oracle10g Documentation References:

Oracle Database Backup and Recovery Basics - more details regarding restore and recovery operations

Oracle Database Backup and Recovery Reference - complete RESTORE;and RECOVER command syntax

NOTE:  Only an entire database can be recovered to a point in time, there is a separate procedure for recovering a tablespace to a point in time. 

Oracle Database Backup and Recovery Advanced User's Guide - information on RMAN Tablespace Point-in-Time Recovery (TSPITR)

 

Reporting on RMAN Operations

The RMAN LIST and REPORT commands, generate reports on backup activities based on the RMAN repository. Use SHOW ALL to display the current RMAN configuration.

14

Page 15: Oracle Rman

Listing Backups

Use LIST to display information about backup sets, proxy copies, and image copies recorded in the repository. The LIST command displays the files against which you can run CROSSCHECK and DELETE commands. Use this command to list:

Backups and copies that do not have the status AVAILABLE in the RMAN repository Backups and copies of datafiles that are available and can possibly be used in a restore operation

Specified archived logs, backup sets, backup pieces, control file copies, datafile copies, and proxy copies

Backups and copies restricted by tag, completion time, recoverability, or device

Incarnations of a specified database or of all databases known to the repository

Stored scripts in the recovery catalog

Reporting on Database Files and Backups

The REPORT command performs more complex analysis than LIST. Use the REPORT command to answer questions such as the following:

Which files need a backup? Which files have not had a backup for some time? 

Which files are not recoverable due to unrecoverable operations? 

Which backup files can be deleted? 

What was the physical schema of the database at a previous time 

 

Oracle10g Documentation References:

See Oracle Database Backup and Recovery Basics - learn how to make lists and reports

See Oracle Database Backup and Recovery Reference - complete LIST and REPORT command syntax

 

Managing the RMAN Repository

RMAN repository metadata is always recorded in the control file of the target database. You can also create a recovery catalog in a separate database, and RMAN will record its metadata there as well.

Monitoring Control File Records :

If you do not use a recovery catalog, then eventually RMAN control file records are overwritten. Set this initialization parameter in the parameter file of the target database to determine how long records are kept:

CONTROL_FILE_RECORD_KEEP_TIME = <number_of_days_to_keep>

15

Page 16: Oracle Rman

You can configure a retention policy to be used by RMAN to determine which backups are considered obsolete.  This allows you to remove files from the repository that are no longer needed to meet your retention requirements.  This policy can be based on a recovery window (the maximum number of days into the past for which you can recover) or redundancy (how many copies of each backed-up file to keep).

The RECOVERY WINDOW parameter of the CONFIGURE command specifies the number of days between the current time and the earliest point of recoverability. RMAN does not consider any full or level 0 incremental backup as obsolete if it falls within the recovery window. Additionally, RMAN retains all archived logs and level 1 incremental backups that are needed to recover to a random point within the window.

Run the CONFIGURE RETENTION POLICY command at the RMAN prompt. This example ensures that you can recover the database to any point within the last week:

 

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS

The REDUNDANCY parameter of the CONFIGURE RETENTION POLICY command specifies how many backups of each datafile and control file that RMAN should keep. In other words, if the number of backups for a specific datafile or control file exceeds the REDUNDANCY setting considers the extra backups as obsolete. The default retention policy is REDUNDANCY=1.

 

As you produce more backups, RMAN keeps track of which ones to retain and which are obsolete. RMAN retains all arcd logs and incremental backups that are needed to recover the nonobsolete backups.

Assume that you make a backup of datafile 7 on Monday, Tuesday, Wednesday, and Thursday. You now have four backups of the datafile. If REDUNDANCY is 2, then the Monday and Tuesday backups are obsolete. If you make another backup on Friday, then the Wednesday backup becomes obsolete.

Run the CONFIGURE RETENTION POLICY command at the RMAN prompt, as in the following example:

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 3;

RMAN does not automatically delete backups rendered obsolete by the retention policy. Instead, RMAN shows them as OBSOLETE in the REPORT OBSOLETE output and in the OBSOLETE column of V$BACKUP_FILES. RMAN deletes obsolete files if you run the DELETE OBSOLETE command.

 Note, backups in the flash recovery area are susceptible to deletion based on RMAN retention policy configuration. 

Oracle10g Documentation References:

Oracle Database Backup and Recovery Basics- more information regarding retention policies and deleting obsolete files  

 

Crosschecking and Deleting Backups

16

Page 17: Oracle Rman

Crosscheck is needed when an archivelog file or backup is manually removed, i.e., not deleted by RMAN.  This command ensures that data about backups in the recovery catalog or control file is synchronized with corresponding data on disk or in the media management catalog.  The CROSSCHECK command operates only on files that are recorded in the recovery catalog or the control file. 

The CROSSCHECK command does not delete any files that it is unable to find, but updates their repository records to EXPIRED. Then, you can run DELETE EXPIRED to remove the repository records for all expired files as well as any existing physical files whose records show the status EXPIRED.

If some backup pieces or copies were erroneously marked as EXPIRED, for example, because the media manager was misconfigured, then after ensuring that the files really do exist in the media manager, run the CROSSCHECK BACKUP command again to restore those files to AVAILABLE status.

Crosschecking Backups

RMAN> # checks RMAN backups on configured devices       CROSSCHECK BACKUP;

      # checks RMAN image copies on configured devices>      CROSSCHECK COPY;

 

If backups are stored with a media manager and sbt channels are not configured, then you must allocate maintenance channel before CROSSCHECK and DELETE commands on sbt devices:

RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;       CROSSCHECK BACKUP;

 

The DELETE command removes RMAN backups and copies from DISK and sbt devices, marks theects as DELETED in the control file, and removes the records from the recovery catalog (if you use a catalog). For example:

RMAN> DELETE BACKUPSET 101, 102, 103;       DELETE CONTROLFILECOPY '/tmp/cf.cpy';       DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 7300;       DELETE BACKUP OF SPFILE TABLESPACE users DEVICE TYPE sbt;       DELETE BACKUP OF DATABASE LIKE '/tmp%'; # pattern match       DELETE ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE sbt;

17