Quick RMAN configuration for disk based backups

This document will detail a quick set up of RMAN for disk based backups using Oracle Database 11gR2 base. It is by no means intended to be an exhaustive introduction to RMAN nor should what is presented be used for production based backup configuration. It is just intended to get your feet wet while exploring the capabilities of RMAN for backup and recovery. See the post Setting up RMAN for backup and recovery using Database Control if you would prefer to perform these steps using the Database Control.

By default the RMAN configuration is stored in the control file. You can see the default values for the configuration parameters by using RMAN to connect to the database and issuing the SHOW ALL command.

[oracle@aries ~]$ rman

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 26 21:26:22 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

RMAN> connect target /

connected to target database: ORCL (DBID=1244946728)

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_orcl.f'; # default

RMAN>

For this example we will only be setting enough parameter to allow us to perform disk based backups meeting the following criteria.

1. The Control File is to be automatically backed up every time a back up is taken and when the structure of the database changes in manner that would require a new backup of the control file.

2. The control file backups are to be stored on disk in the /u01/app/oracle/oradata/orcl/backup directory.

3. The backups should be made using backup sets and stored on disk.

4. Each backup set piece size should be 2GB or smaller in size and should be stored on disk in the /u01/app/oracle/oradata/orcl/backup directory.

5. Since this is a test database we only want to keep the last two backups made.

Configuring RMAN

Changing the configuration in RMAN is fairly straightforward. If you look back at the output from the show all command above, you will notice that each line begins with CONFIGURE and end in a semi colon representing a complete command set the configuration item. You could copy and paste one of those lines in an RMAN prompt.

For example we will copy the configure line for BACKUP OPTIMIZATION.

RMAN> CONFIGURE BACKUP OPTIMIZATION OFF; # default

new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION OFF;
new RMAN configuration parameters are successfully stored

RMAN>

If you make a mistake you or other wise wish to clear the configuration you can use CLEAR to rest the configuration parameter to its default value.

RMAN> CONFIGURE BACKUP OPTIMIZATION CLEAR;        

old RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION OFF;
RMAN configuration parameters are successfully reset to default value

RMAN> 

Parameters that are set at their default value will have the # default at the end of line.

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default

1. The control file is to be automatically backed up every time a back up is taken and when the structure of the database changes in manner that would require a new backup of the control file.

How many times have you added new data files to a table space or created a table space and forgot to backup the control file? RMAN can be configured to automatically backup the control file when a data file is added or when a backup is taken with CONTROLFILE AUTOBACKUP. By default CONTROLFILE AUTOBACKUP is set to OFF.

RMAN> configure controlfile autobackup on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN>

2. The control file backups are to be stored on disk in the /u01/app/oracle/oradata/orcl/backup directory.

To set the location in which to write the control file auto backup you will need to set the FORMAT for the CONTROLFILE AUTOBACKUP. By default the FORMAT has only the substitution variable %F which translates into c--YYYYMMDD-QQ. For example the control file auto back for this database would be c-1244946728-20100601-00. The value 1244946728 is the database ID, 20100601 is the date and 00 is the sequence number in hexadecimal.

The %F has to be in the FORMAT and there can be no other substitution variables.

RMAN> configure controlfile autobackup format for device type disk to '/u01/app/oracle/oradata/orcl/backup/%F';

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/oradata/orcl/backup/%F';
new RMAN configuration parameters are successfully stored

RMAN>

3. The backups should be made using backup sets and stored on disk.

RMAN can store the backup in one or more binary files called a backup set that contain data from one ore more data files, archive logs, control files or an SPFILE. These files are written in an RMAN specific format and be compressed during the creation process. Each individual file in a back set is called a backup piece.

RMAN can also create exact copies of the data files, archive logs, control files and SPFILE. These image copies are not created in an RMAN specific format.

In RMAN the type of backup is configured via the device type to be used to create the backup. By default the default device type is disk and RMAN is configured to write backup sets to disk.

RMAN> show default device type;

RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

RMAN> show device type;

RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

RMAN> 

So this requirement is already present by default.

4. Each backup set piece size should be 2GB or smaller in size and should be stored on disk in the /u01/app/oracle/oradata/orcl/backup directory.

In order for RMAN to read or write data it must have a channel configured. In configuring the channel we can set the FORMAT, or location on disk, in which to read and write backups. The channel is also were we configure the size of the backup piece in the case of backup sets.

Like the CONTROLFILE AUTOBACKUP FORMAT, the CHANNEL FORMAT has a substitution variable %U. The %U specifies a system generated unique file name. There are other substitution variables that can be used in place or in conjunction with the %U see the documentation Oracle Database Backup and Recovery Reference for a complete list. Unlike the CONTROLFILE AUTOBACKUP FORMAT you can have multiple substitution variables.

RMAN> configure channel device type disk format '/u01/app/oracle/oradata/orcl/backup/%U' maxpiecesize 2 G;

new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/oracle/oradata/orcl/backup/%U' MAXPIECESIZE 2 G;
new RMAN configuration parameters are successfully stored

RMAN>

5 Keep only the last two backups made.

When discussing how long to keep a backup we are talking about a retention policy. Using RMAN you can choose a recovery window (have a rolling window of days), or a set redundancy (rolling number of backups).

One thing to keep in mind is that when you specify a recovery window you are specifying how many days you want to keep not the number of backups, and when you specify a redundancy you are stating how many backups you want to keep not the number of days.

In this example we have set the Redundancy to two so we are always going to keep the last two backups regardless of how old they are.

RMAN> configure retention policy to redundancy 2;

new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored

RMAN>

Test out the configuration

At this time we have a very basic configuration for disk based backup. We can test this out with a simple backup. The output below is from the database configured in this document. Since this database is not in archive log mode a cold backup was taken.

[oracle@aries ~]$ rman

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jun 1 13:16:20 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

RMAN> connect target /

connected to target database: ORCL (DBID=1244946728, not open)

RMAN> backup database;

Starting backup at 01-JUN-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 01-JUN-10
channel ORA_DISK_1: finished piece 1 at 01-JUN-10
piece handle=/u01/app/oracle/oradata/orcl/backup/02lf51pj_1_1 tag=TAG20100601T131635 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:06
Finished backup at 01-JUN-10

Starting Control File and SPFILE Autobackup at 01-JUN-10
piece handle=/u01/app/oracle/oradata/orcl/backup/c-2502578563-20100601-00 comment=NONE
Finished Control File and SPFILE Autobackup at 01-JUN-10

RMAN> alter database open; 

database opened

RMAN> 

This configuration is enough to get you started in exploring backup and recovery with RMAN.

5 thoughts on “Quick RMAN configuration for disk based backups”

  1. Hello Eric
    I am very new to RMAN and configured the RMAN backup against the guidelines posted with your thread.
    Now, each time I run the database backup, the backups are stored in the single location, for example D:\oracle\rman\backup. How I can force RMAN to create folders like 2015_11_24 as it happens with Oracle’s automatic backups?

    regards,

  2. Can we configure
    DATAFILE BACKUP COPIES
    ARCHIVELOG BACKUP COPIES
    CONTROLFILE AUTOBACKUP
    to a disk other than default

  3. Hi blogger, i must say you have very interesting posts here.
    Your page can go viral. You need initial traffic boost only.
    How to get it? Search for: Mertiso’s tips go viral

Leave a Reply

Your email address will not be published. Required fields are marked *