What Is RMAN Backup In Oracle

Explain what is RMAN?

Recovery Manager is a tool that manages the process of creating backups and also manages the process of restoring and recovering from them.

Explain why should use RMAN?

The advantages are:

  • No extra costs asits available free.
  • RMAN introduced in Oracle 8 it has become simpler with newer versions and easier than user managed backups.
  • Proper security.
  • You are 100% sure your database has been backed up.
  • Its contains detail of the backups taken etc in its central repository.
  • Facility for testing validity of backups also commands like crosscheck to Check the status of backup.
  • Faster backups and restores compared to backups without RMAN
  • RMAN is the only backup tool which supports incremental backups.
  • Oracle 10g onwards has got further optimized incremental backup which has resulted in improvement of performance during backup and recovery time
  • Parallel operations are supported.
  • Better querying facility for knowing different details of backup.
  • No extra redo generated when backup is taken as compared to online backup without RMAN which results in saving of space in hard disk.
  • RMAN is an intelligent tool.
  • Maintains repository of backup metadata.
  • Remembers backup set location.
  • Knows what need to backed up.
  • Knows what is required for recovery.
  • Knows what backup are redundant.
Explain the RMAN Architecture.

The RMAN architecture are as follows:

  • An oracle RMAN comprises of RMAN EXECUTABLE. This could be present and fired even through client side TARGET DATABASE. This is the database which needs to be backed up.
  • RECOVERY CATALOG - The recovery catalog is optional.  Otherwise the backup details are stored in target database controlfile.  Recovery catalog is a must in following scenarios:
  • In order to store scripts.
  • For tablespace point in time recovery
  • It is a repository of information queried and updated by Recovery Manager.
  • It is a schema or user stored in Oracle database.
  • One schema can support many databases.
  • It contains information about physical schema of target database datafile and archive log, backup sets and pieces.
Media Management Software

Media Management software is a must if you are using RMAN for storing backup in tape drive directly.

Backups in RMAN

Oracle backups in RMAN are of the following type:

RMAN complete backup OR RMAN incremental backup.

These backups are of RMAN proprietary nature.

IMAGE COPY

Its again a kind of backup. The advantage of uing Image copy is its not in RMAN proprietary format.
Backup Format

RMAN backup is not in oracle format but in RMAN format. Oracle backup comprises of backup sets and it consists of backup pieces. Backup sets are logical entity. In oracle 9i it gets stored in a default location.

There are two type of backup sets:

1. Datafile backup sets,
2. Archivelog backup sets

One more important point of data file backup sets is it do not include empty blocks. A backup set would contain many backup pieces. A single backup piece consists of physical files which are in RMAN proprietary format.

You can go to RMAN prompt by just typing rman. RMAN executable is present in ORACLE_HOME/bin location.

bash-2.05$ rman

You can use target connect to connect to database. The database it will connect to depends on the environment variable ORACLE_HOME.

RMAN> connect target

Alternatively you can use “rman TARGET SYS/oracle@test NOCATALOG” to connect to the RMAN of “test” instance.

Here we will be using target database control file to store all the information required for RMAN, like backupsets and backup image information etc.

Backup Database:

RMAN> shutdown immediate
RMAN> startup mount;
RMAN> backup database;
Creating RMAN Catalog

You can also create a repository for RMAN to store all this information. Repository will be just another small database which can store the catalog information. Creating a catalog is a 3 step process

1) Create database which will hold the catalog. Else you can use the existing database also. All you need is to create a seperate tablespace for holding the information about RMAN catalog.

2) Create RMAN tablespace and RMAN user

SQL> create tablespace rman_tbs datafile ‘/dy/oracle/product/db10g/dbf/rman01.dbf’ size 500M EXTENT MANAGEMENT LOCAL segment SPACE MANAGEMENT AUTO ;

Tablespace created.

SQL> create user rman identified by rman
  2  default tablespace rman_tbs
  3  TEMPORARY TABLESPACE TEMPTS1
  4  QUOTA UNLIMITED ON rman_tbs account unlock;

User created.

After creating user, you need to grant RECOVERY_CATALOG_OWNER role to that user.

SQL> grant recovery_catalog_owner to rman;

Grant succeeded.

3) Now Create RMAN catalog.

bash-2.05$ rman catalog rman/rman@test

connected to recovery catalog database

RMAN> create catalog

For registering the database, you need to get connected to database as well as catalog at the same time. Here is how you can do.

RMAN> connect target
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-06004: ORACLE error from recovery catalog database:
RMAN-20001: target database not found in recovery catalog

The above error is because the database we connected to is not found in the catalog database. We can register the database in catalog.

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

Registering database will also resynch the information present in the target database control file and catalog database. Since we have taken 1 backup early, it will synchup that information with RMAN catalog. We can check the same using LIST BACKUP command at RMAN prompt.

RMAN> list backup;
RMAN Command line

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 (when we are not using a seperate catalog for RMAN).
RMAN> configure controlfile autobackup on;

Backing up control file

RMAN> backup current controlfile;

Creating Image copy of all datafiles in database

These are the image copies and are stored in ORACLE format and not in RMAN format. Backupsets and backuppieces are stored in internal RMAN format. Hence these image copies can be used for manual restore and recovery as well.

RMAN> backup as copy database;

Creating backupsets of all datafiles in 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.

RMAN> backup as backupset database;

Backup individual tablespace as backupsets

RMAN> backup tablespace system, HTMLDB;

Backup individual tablespace as image copies

RMAN> backup as copy tablespace system;

Backup individual files as image copies

RMAN> backup as copy datafile ‘/dy/oracle/product/db10g/dbf/system01.dbf’;

Backup individual files as Backupsets

RMAN> backup datafile ‘/dy/oracle/product/db10g/dbf/system01.dbf’;

Backup archivelogs

We can backup the archive logs according to the output of some search condition. Example we want to backup only those archivelogs which starts with “ARCH_616814159_”.

RMAN> backup acrchivelog like ‘%ARCH_616814159_%’;

Copy archivelogs from some time stamp.

Suppose we want to copy the archivelogs of last 2 days, then we can use the following commands.

RMAN> BACKUP ARCHIVELOG from time ’sysdate-2?;

Backup all archivelog files

RMAN> Backup archivelog all;

Backup archivelog between some time.

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

Specifying copies while backing up.

RMAN> backup copies 2 datafile ‘/dy/oracle/product/db10g/dbf/cs_tbs01.dbf’;

Remember that copies option cannot be used with image copies. It can be used only with backupsets.

Giving tags to backups

RMAN> BACKUP TAG ‘weekly_full_db_bkup’ DATABASE MAXSETSIZE 100M;
Backing up backupsets
RMAN> BACKUP BACKUPSET ALL;

Backup imagecopies

RMAN> Backup as copy backupset all;

List Imagecopies

RMAN> list copy;

List Backupsets

RMAN> list backup;

Oracle Database

See Also
RMAN Backup Scripts

Have a Oracle Question
Do you have an Oracle Question?

Oracle Books
Oracle Certification, Database Administration, SQL, Application, Programming Reference Books

Oracle Application
Oracle Application Hints and Tips

Oracle Home
Oracle Database, SQL, Application, Programming Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.