Create your own RMAN backup scripts from the scratch

This guide is intended for Oracle Database medium/high level administrators to have a reference for creating RMAN scripts from the scratch, based on retention policies for physical backups on databases in archive log mode.

If we’re planning to backup an Oracle RAC database, we’d like to have the scripts we’ll create replicated in all the RAC nodes and set the backup storage location to a shared ocfs2/ASMFS disk so we can have “High Availability Oracle RAC RMAN Backups”.

First of all, if not already, we’ll “change the database into archive log mode”.

Then, we connect using RMAN to the Oracle database instance that we are going to use for the backup:
 

[oracle@rac1 ~]$ rman target / nocatalog 

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jul 5 13:35:50 2011 

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

connected to target database: RACORA (DBID=4104435745) 
using target database control file instead of recovery catalog 

RMAN> 

RMAN> show all; 

RMAN configuration parameters for database with db_unique_name RACORA are: 

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/db_1/dbs/snapcf_RACORA1.f'; # default 

From which we’ll keep the following lines for making our scripts configuration file:
 

# how many days we want to keep backups on disk before RMAN deletes them
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default 

# enable/disable automatic backup of spfile and controlfile
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default 

# string with the destination of the automatic backup of the spfile and controlfile
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default 

# Define parallelism degree by an integer.(Only usable on Enterprise Edition)
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default 

# Set the compression program. (Why not to use bz2 for compression? ;-)
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default 

# Set the destination of the snapshot control file to be kept on the backups. 
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_RACORA1.f'; # default 

Now we’ll choose a backup destination for datafile backups, archived logs backups and the scripts and configuration file.

We really want the backup script outside our $ORACLE_HOME for if we need to reinstall our Oracle binaries (aka. In case of a downgrade needed) won’t have to worry or remember about them.

But it really can be a directory on our $ORACLE_BASE, so we’ll choose “$ORACLE_BASE/backups/” for the backup root path.

The paths as well the scripts themselves have to be owned by the system’s oracle user.

[oracle@rac1 ~]$ mkdir $ORACLE_BASE/backups
[oracle@rac1 ~]$ mkdir /u01/app/oracle/backups/
[oracle@rac1 ~]$ mkdir $ORACLE_BASE/backups/archivelogs
[oracle@rac1 ~]$ mkdir $ORACLE_BASE/backups/datafiles
[oracle@rac1 ~]$ mkdir $ORACLE_BASE/backups/controlspfile

On the other hand, we really want the backup scripts to be placed on or near our backup destination, and that’s cause the disk filesystem backup will keep the copy to tape of the backup sets as well as the copy of the version of the scripts on the moment the backup is launched. This can be very useful to revert failures on the scripts after a backups fail cause of unwanted changes on the backup scripts.
 

[oracle@rac1 ~]$ mkdir $ORACLE_BASE/backups/scripts
[oracle@rac1 ~]$ mkdir $ORACLE_BASE/backups/scripts/conf

Then, we create a configuration file for the script pasting the rman parameters as we collected them before, but changing the parameters with the information we already know or have decided:
 

[oracle@rac1 ~]$ vi /u01/app/oracle/backups/scripts/conf/rmanbackup.cfg

# how many days we want to keep backups on disk before RMAN deletes them
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; 

# enable/disable automatic backup of spfile and controlfile
CONFIGURE CONTROLFILE AUTOBACKUP ON; 

# string with the destination of the automatic backup of the spfile and controlfile
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$ORACLE_BASE/backups/controlspfile
/%F'; 

# Define parallelism degree by an integer (only usable on Enterprise Edition), and if the backupset is going to be compressed.
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET; 

# Set the compression program. (Why not to use bz2 for compression? ;-)
CONFIGURE COMPRESSION ALGORITHM 'BASIC'; 
# Set the destination of the snapshot control file to be kept on the backups. 
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '$ORACLE_BASE/backups/controlspfile
/snapcf_RACORA1.f'; 

Now, we need to add some extra parameters to the configuration file to add the destination of the backupsets for which RMAN will launch the channels we set up and the maximum size of each backup piece on the backupset, which we’ll set to 4GB, as it’s a handy file size for a decent system:
 

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '$ORACLE_BASE/backups/datafiles
/%d_%T_s%s_s%p' MAXPIECESIZE 4G;

If your backup destination is a vfat(fat32) partition (WindowsXP-Windows95) the MAXPIECESIZE should be set to 2GB or the backup pieces will get corrupted.

Where the parameter strings in the format stands for:
 

%d  The name of the database. 
%T  The year, month, and day (YYYYMMDD)
%s  The backup set number.
%p  The piece number within the backup set.

Now we have our configuration file ready, but it contains RMAN commands, that set the options once running the RMAN tool, and we don’t really want commands running on our configuration file, do we? So we’ll save the “CONFIGURE” lines on the backup script and change them to fancy fashion variable names and their values.
 

[oracle@rac1 ~]$ cat /u01/app/oracle/backups/scripts/conf/rmanbackup.cfg > /u01/app/oracle/backups/scripts/rmanbackup.sh

The result would be something like this:
 

# how many days we want to keep backups on disk before RMAN deletes them
REDUNDANCY=1

# enable/disable automatic backup of spfile and controlfile
CONTROLFILE_AUTOBACKUP="ON"

# string with the destination of the automatic backup of the spfile and controlfile
CONTROLFILE_AUTOBACKUP_FORMAT="$ORACLE_BASE/backups/controlspfile/%F"

# Define parallelism degree by an integer (only usable on Enterprise Edition)
PARALLELISM=1 

# and if the backupset is going to be compressed.
BACKUPSET_TYPE="COMPRESSED BACKUPSET"

# Set the compression program. (Why not to use bz2 for compression? ;-)
COMPRESSION_ALGORITHM="BASIC"

# Set the destination of the snapshot control file to be kept on the backups. 
SNAPSHOT_CONTROLFILE="$ORACLE_BASE/backups/controlspfile/snapcf_RACORA1.f"

DATAFILES_DEST="$ORACLE_BASE/backups/datafiles/%d_%T_s%s_s%p" 
ARCHIVELOGS_DEST="$ORACLE_BASE/backups/archivelogs/%d_%T_s%s_s%p" 

MAXPIECESIZE="4G"

Now, we open the script we just saved before with the “CONFIGURE” lines and swap the parameter with the variable names in the configuration file:
 

CONFIGURE RETENTION POLICY TO REDUNDANCY $REDUNDANCY;
CONFIGURE CONTROLFILE AUTOBACKUP $CONTROLFILE_AUTOBACKUP;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$CONTROLFILE_AUTOBACKUP_FORMAT';       
CONFIGURE DEVICE TYPE DISK PARALLELISM $PARALLELISM BACKUP TYPE TO $BACKUPSET_TYPE;
CONFIGURE COMPRESSION ALGORITHM '$COMPRESSION_ALGORITHM';
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '$SNAPSHOT_CONTROLFILE';
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '$DATAFILES_DEST' MAXPIECESIZE $MAXPIECESIZE;

We test the script and configuration file. To do that, first we need to complete the script loading the configuration file and connecting to RMAN so we add the following at the beginning of the script:
 

#!/bin/bash

source ~/.bash_profile # $ORACLE_HOME and $ORACLE_SID should be exported here 

source $ORACLE_BASE/backups/scripts/conf/rmanbackup.cfg

rman target / nocatalog <<EOF

...
EOF

Notice that new parameters have appeared, so we’ll need to add them to our configuration file and substitute them as needed.

Now we’ve got the script and configuration file ready to test them. This is how they look as they are:
 

[oracle@rac1 ~]$ cat /u01/app/oracle/backups/scripts/conf/rmanbackup.cfg
# how many days we want to keep backups on disk before RMAN deletes them
REDUNDANCY=1

# enable/disable automatic backup of spfile and controlfile
CONTROLFILE_AUTOBACKUP="ON"

# string with the destination of the automatic backup of the spfile and controlfile
CONTROLFILE_AUTOBACKUP_FORMAT="$ORACLE_BASE/backups/controlspfile/%F"

# Define parallelism degree by an integer (only usable on Enterprise Edition)
PARALLELISM=1 

# and if the backupset is going to be compressed.
BACKUPSET_TYPE="COMPRESSED BACKUPSET"

# Set the compression program. (Why not to use bz2 for compression? ;-)
COMPRESSION_ALGORITHM="BASIC"

# Set the destination of the snapshot control file to be kept on the backups. 
SNAPSHOT_CONTROLFILE="$ORACLE_BASE/backups/controlspfile/snapcf_RACORA1.f"

DATAFILES_DEST="$ORACLE_BASE/backups/datafiles/%d_%T_s%s_s%p" 
ARCHIVELOGS_DEST="$ORACLE_BASE/backups/archivelogs/%d_%T_s%s_s%p" 

MAXPIECESIZE="4G"

[oracle@rac1 ~]$ cat /u01/app/oracle/backups/scripts/rmanbackup.sh
#!/bin/bash

source ~/.bash_profile # $ORACLE_HOME and $ORACLE_SID should be exported here

source $ORACLE_BASE/backups/scripts/conf/rmanbackup.cfg

rman target / nocatalog <<EOF
CONFIGURE RETENTION POLICY TO REDUNDANCY $REDUNDANCY; 
CONFIGURE CONTROLFILE AUTOBACKUP $CONTROLFILE_AUTOBACKUP; 
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$CONTROLFILE_AUTOBACKUP_FORMAT'; 
CONFIGURE DEVICE TYPE DISK PARALLELISM $PARALLELISM BACKUP TYPE TO $BACKUPSET_TYPE; 
CONFIGURE COMPRESSION ALGORITHM '$COMPRESSION_ALGORITHM'; 
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '$SNAPSHOT_CONTROLFILE'; 
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '$DATAFILES_DEST' MAXPIECESIZE $MAXPIECESIZE;
exit;
EOF
exit

We set the script as executable and launch the script to test it:
 

[oracle@rac1 ~]$ chmod +x /u01/app/oracle/backups/scripts/rmanbackup.sh
[oracle@rac1 ~]$ /u01/app/oracle/backups/scripts/rmanbackup.sh


Recovery Manager: Release 11.2.0.1.0 - Production on Fri Jul 8 14:24:24 2011

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

connected to target database: RACORA (DBID=4104435745)
using target database control file instead of recovery catalog

RMAN> 
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters are successfully stored

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

RMAN> 
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backups/controlspfile/%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backups/controlspfile/%F';
new RMAN configuration parameters are successfully stored

RMAN> 

old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters are successfully stored

RMAN> 
new RMAN configuration parameters:
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE;
new RMAN configuration parameters are successfully stored

RMAN> 
old RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/backups/controlspfile/snapcf_RACORA1.f';
new RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/backups/controlspfile/snapcf_RACORA1.f';
new RMAN configuration parameters are successfully stored

RMAN> 
old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backups/datafiles/%d_%T_s%s_s%p' MAXPIECESIZE 4 G;
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backups/datafiles/%d_%T_s%s_s%p' MAXPIECESIZE 4 G;
new RMAN configuration parameters are successfully stored

RMAN> 

Recovery Manager complete.

Then, we can add the backup commands, one for the full backup. The backup commands are, as shown on “my Oracle Cookbook”:
 

backup database plus archivelog;
backup archivelog all delete input;

But we want to decide on the same script if we’re going to backup the full database (and the archivelogs to recover the datafiles up to the backup’s SCN) or just the archivelogs. So we’ll have to parse the option to the script as an argument.

The final resulting script will be:
 

#!/bin/bash

source ~/.bash_profile # $ORACLE_HOME and $ORACLE_SID should be exported here

source $ORACLE_BASE/backups/scripts/conf/rmanbackup.cfg

usage() {
        echo `basename $0`: ERROR: $* 1>&2
        echo usage: `basename $0` '[-[af]]' 1>&2
        exit 1
}

case "$1" in
        -a) BACKUP_TYPE="archivelog all format '$ARCHIVELOGS_DEST' delete input";;
        -f) BACKUP_TYPE="database plus archivelog";;
        *) usage ;; 
esac

rman target / nocatalog <<EOF
CONFIGURE RETENTION POLICY TO REDUNDANCY $REDUNDANCY; 
CONFIGURE CONTROLFILE AUTOBACKUP $CONTROLFILE_AUTOBACKUP; 
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$CONTROLFILE_AUTOBACKUP_FORMAT'; 
CONFIGURE DEVICE TYPE DISK PARALLELISM $PARALLELISM BACKUP TYPE TO $BACKUPSET_TYPE; 
CONFIGURE COMPRESSION ALGORITHM '$COMPRESSION_ALGORITHM'; 
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '$SNAPSHOT_CONTROLFILE'; 
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '$DATAFILES_DEST' MAXPIECESIZE $MAXPIECESIZE;
backup $BACKUP_TYPE;
exit;
EOF
exit

With the configuration file as follows:
 

[oracle@rac1 ~]$ cat /u01/app/oracle/backups/scripts/conf/rmanbackup.cfg
# how many days we want to keep backups on disk before RMAN deletes them
REDUNDANCY=1

# enable/disable automatic backup of spfile and controlfile
CONTROLFILE_AUTOBACKUP="ON"

# string with the destination of the automatic backup of the spfile and controlfile
CONTROLFILE_AUTOBACKUP_FORMAT="$ORACLE_BASE/backups/controlspfile/%F"

# Define parallelism degree by an integer (only usable on Enterprise Edition)
PARALLELISM=1 

# and if the backupset is going to be compressed.
BACKUPSET_TYPE="COMPRESSED BACKUPSET"

# Set the compression program. (Why not to use bz2 for compression? ;-)
COMPRESSION_ALGORITHM="BASIC"

# Set the destination of the snapshot control file to be kept on the backups. 
SNAPSHOT_CONTROLFILE="$ORACLE_BASE/backups/controlspfile/snapcf_RACORA1.f"

DATAFILES_DEST="$ORACLE_BASE/backups/datafiles/%d_%T_s%s_s%p" 
ARCHIVELOGS_DEST="$ORACLE_BASE/backups/archivelogs/%d_%T_s%s_s%p" 

MAXPIECESIZE="4G"

And it’s done! If you have a multi-instance RAC, you’d need to add the paramaters $ORACLE_HOME and $ORACLE_SID to the logic of the script as well for configuring RMAN to connect to a catalog database, but we’ll keep that for another posts ^_^.

Let’s test the scripts:
 

[oracle@rac1 ~]$ /u01/app/oracle/backups/scripts/rmanbackup.sh
rmanbackup.sh: ERROR:
usage: rmanbackup.sh [-[af]]

With “-a” for archivelog backup:
 

[oracle@rac1 ~]$ /u01/app/oracle/backups/scripts/rmanbackup.sh -a

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Jul 8 16:36:42 2011

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

connected to target database: RACORA (DBID=4104435745)
using target database control file instead of recovery catalog

RMAN> 
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters are successfully stored

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

RMAN> 
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backups/controlspfile/%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backups/controlspfile/%F';
new RMAN configuration parameters are successfully stored

RMAN> 
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters are successfully stored

RMAN> 
old RMAN configuration parameters:
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE;
new RMAN configuration parameters:
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE;
new RMAN configuration parameters are successfully stored

RMAN> 
old RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/backups/controlspfile/snapcf_RACORA1.f';
new RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/backups/controlspfile/snapcf_RACORA1.f';
new RMAN configuration parameters are successfully stored

RMAN> 
old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backups/datafiles/%d_%T_s%s_s%p' MAXPIECESIZE 4 G;
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backups/datafiles/%d_%T_s%s_s%p' MAXPIECESIZE 4 G;
new RMAN configuration parameters are successfully stored

RMAN> 
Starting backup at 08-JUL-11
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=35 instance=RACORA1 device type=DISK
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=27 RECID=2 STAMP=755700601
input archived log thread=2 sequence=13 RECID=1 STAMP=755696179
input archived log thread=1 sequence=28 RECID=3 STAMP=755780576
input archived log thread=1 sequence=29 RECID=4 STAMP=755955454
input archived log thread=1 sequence=30 RECID=5 STAMP=755973413
channel ORA_DISK_1: starting piece 1 at 08-JUL-11
channel ORA_DISK_1: finished piece 1 at 08-JUL-11
piece handle=/u01/app/oracle/backups/archivelogs/RACORA_20110708_s1_s1 tag=TAG20110708T163654 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
channel ORA_DISK_1: deleting archived log(s)
archived log file name=+DATA/racora/archivelog/1_27_729858920.dbf RECID=2 STAMP=755700601
archived log file name=/u01/app/oracle/product/11.2.0/db_1/dbs/arch2_13_729858920.dbf RECID=1 STAMP=755696179
archived log file name=+DATA/racora/archivelog/1_28_729858920.dbf RECID=3 STAMP=755780576
archived log file name=+DATA/racora/archivelog/1_29_729858920.dbf RECID=4 STAMP=755955454
archived log file name=+DATA/racora/archivelog/1_30_729858920.dbf RECID=5 STAMP=755973413
Finished backup at 08-JUL-11

Starting Control File and SPFILE Autobackup at 08-JUL-11
piece handle=/u01/app/oracle/backups/controlspfile/c-4104435745-20110708-00 comment=NONE
Finished Control File and SPFILE Autobackup at 08-JUL-11

RMAN> 
RMAN> 

Recovery Manager complete.

And with “-f” for full database backup:
 

[oracle@rac1 ~]$ /u01/app/oracle/backups/scripts/rmanbackup.sh -f

Recovery Manager: Release 11.2.0.1.0 - Production on Fri Jul 8 16:40:05 2011

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

connected to target database: RACORA (DBID=4104435745)
using target database control file instead of recovery catalog

RMAN> 
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters are successfully stored

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

RMAN> 
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backups/controlspfile/%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/backups/controlspfile/%F';
new RMAN configuration parameters are successfully stored

RMAN> 
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;
new RMAN configuration parameters are successfully stored

RMAN> 
old RMAN configuration parameters:
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE;
new RMAN configuration parameters:
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE;
new RMAN configuration parameters are successfully stored

RMAN> 
old RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/backups/controlspfile/snapcf_RACORA1.f';
new RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/backups/controlspfile/snapcf_RACORA1.f';
new RMAN configuration parameters are successfully stored

RMAN> 
old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backups/datafiles/%d_%T_s%s_s%p' MAXPIECESIZE 4 G;
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/oracle/backups/datafiles/%d_%T_s%s_s%p' MAXPIECESIZE 4 G;
new RMAN configuration parameters are successfully stored

RMAN> 

Starting backup at 08-JUL-11
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=35 instance=RACORA1 device type=DISK
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=31 RECID=6 STAMP=755973614
channel ORA_DISK_1: starting piece 1 at 08-JUL-11
channel ORA_DISK_1: finished piece 1 at 08-JUL-11
piece handle=/u01/app/oracle/backups/datafiles/RACORA_20110708_s3_s1 tag=TAG20110708T164015 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-JUL-11

Starting backup at 08-JUL-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/racora/datafile/system.260.729858643
input datafile file number=00002 name=+DATA/racora/datafile/sysaux.261.729858653
input datafile file number=00003 name=+DATA/racora/datafile/undotbs1.269.729858657
input datafile file number=00005 name=+DATA/racora/datafile/example.263.729858985
input datafile file number=00006 name=+DATA/racora/datafile/undotbs2.262.729859525
input datafile file number=00004 name=+DATA/racora/datafile/users.268.729858659
channel ORA_DISK_1: starting piece 1 at 08-JUL-11
channel ORA_DISK_1: finished piece 1 at 08-JUL-11
piece handle=/u01/app/oracle/backups/datafiles/RACORA_20110708_s4_s1 tag=TAG20110708T164017 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:07
Finished backup at 08-JUL-11

Starting backup at 08-JUL-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=32 RECID=7 STAMP=755973746
channel ORA_DISK_1: starting piece 1 at 08-JUL-11
channel ORA_DISK_1: finished piece 1 at 08-JUL-11
piece handle=/u01/app/oracle/backups/datafiles/RACORA_20110708_s5_s1 tag=TAG20110708T164226 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-JUL-11

Starting Control File and SPFILE Autobackup at 08-JUL-11
piece handle=/u01/app/oracle/backups/controlspfile/c-4104435745-20110708-01 comment=NONE
Finished Control File and SPFILE Autobackup at 08-JUL-11

RMAN> 
RMAN> 

Recovery Manager complete.

2 Comments

  • Horacio Miranda says:

    This is ok for small databases, for large system (also if you want speed on this backup) you must add the line : “filesperset 2″ for the datafiles and “filesperset 20″ for the archive.

    Why ? if you neeed recover one single datafile you need to read a big chunk file and take what you need from that file.

    and by default the rman do #Datafiles/#channels = filesperset

    So if you have only one channel you will create one big file with the datafiles, if you use the default from Oracle, you will use 16 channels, but for large systems (example 300 datafiles with 30G each) you need to speed the recover if something happen.

    I hope this help, I do work on RAC large system (Over 10T) and all the time I try to explain do for small and for big environments all you build for the people around. (like try for n=1, n=2 … n=n and n=n+1) if work for n=n then it is OK.

    • egfh says:

      Hhhmmm… Don’t think so.

      With the “MAXPIECESIZE 4G;” option, which is on the guide, you never get a file bigger than 4GB, therefore, you never get huge datafiles backup pipeces (IMHO, at the present day 4GB is nothing for a DB).

      Edit: Also, if you depend on parallel channels you’re tied up by the Enterprise Edition. This way the guide is suitable for both Enterprise and Standard Editions.