Tuesday, September 20, 2011

Basic RMAN Back-up Scenarios


Following scenarios are covered in this article


1.      Backup control files
2.      Backup SP files
3.      Backup Data files
4.      Backup Tablespaces
5.      Backup Database
6.      Backup Archived log files


Backing up Control Files:

First configure the control file autobackup option. This will let control files and spfile be backed up whenever any structural changed is performed to the database or backup command is issued

RMAN> configure controlfile autobackup on;

However, if autobackup option is not supposed to be set for whatever reason, you can also manually backup your control file as show below

RMAN> backup current controlfile;

or

RMAN> backup datafile 2 include current controlfile;


Starting backup at 20-SEP-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=56 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=00002 name=/u02/oradata/extdev/datafiles/sysaux01.dbf

channel ORA_DISK_1: starting piece 1 at 20-SEP-11
channel ORA_DISK_1: finished piece 1 at 20-SEP-11
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/m8mn1bfp_1_1 tag=TAG20110920T142809 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 20-SEP-11
channel ORA_DISK_1: finished piece 1 at 20-SEP-11
piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/m9mn1bie_1_1 tag=TAG20110920T142809 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20-SEP-11

Starting Control File and SPFILE Autobackup at 20-SEP-11
piece handle=/u02/backups/c-3110907604-20110920-02 comment=NONE
Finished Control File and SPFILE Autobackup at 20-SEP-11


Backing up SP files (Server Parameter File):

In order to backup the SPFile, make sure you have mounted the database using SP File as  the backup command won’t work if the instance is mounted using init.ora file
If auto backup option is set to on then control file will also get backed up after issuing the above command as shown below

RMAN> backup spfile;

Starting backup at 20-SEP-11

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 20-SEP-11

channel ORA_DISK_1: finished piece 1 at 20-SEP-11

piece handle=/u01/app/oracle/product/11.2.0/db_1/dbs/mbmn1bvg_1_1 tag=TAG20110920T143632 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 20-SEP-11


Starting Control File and SPFILE Autobackup at 20-SEP-11

piece handle=/u02/backups/c-3110907604-20110920-03 comment=NONE

Finished Control File and SPFILE Autobackup at 20-SEP-11

Backing up Data Files:

In order to backup individual files rather than complete database, use the below command either of the following option
1.      In the Run block and allocating a channel
2.      Configuring the channel

Option 1:

RMAN>run
2> {
3> allocate channel c1 device type disk;
4>  backup datafile 2
5> format '/u02/backups/datafile_backups/%d_%U.bk';
6> }
released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=56 device type=DISK
Starting backup at 20-SEP-11
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u02/oradata/extdev/datafiles/sysaux01.dbf
channel c1: starting piece 1 at 20-SEP-11
channel c1: finished piece 1 at 20-SEP-11
piece handle=/u02/backups/datafile_backups/EXTDEV_mdmn1csi_1_1.bk tag=TAG20110920T145202 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:35
Finished backup at 20-SEP-11

Starting Control File and SPFILE Autobackup at 20-SEP-11
piece handle=/u02/backups/c-3110907604-20110920-04 comment=NONE
Finished Control File and SPFILE Autobackup at 20-SEP-11
released channel: c1

Option 2:

RMAN> configure channel device type disk
format '/u02/backups/datafile_backups/%d_%U.bk';
RMAN> backup datafile 2;

Backing up Tablespaces:

Just like backup datafile, tablespaces can also be backed up

RMAN>run
2> {
3> allocate channel c1 device type disk;
4>  backup tablespace users
5> format '/u02/backups/datafile_backups/%d_%U.bk';
6> }
allocated channel: c1
channel c1: SID=56 device type=DISK

Starting backup at 20-SEP-11
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u02/oradata/extdev/datafiles/users01.dbf
channel c1: starting piece 1 at 20-SEP-11
channel c1: finished piece 1 at 20-SEP-11
piece handle=/u02/backups/tablespace_backupsEXTDEV_mfmn1fue_1_1.bk tag=TAG20110920T154414 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:55
Finished backup at 20-SEP-11

Starting Control File and SPFILE Autobackup at 20-SEP-11
piece handle=/u02/backups/c-3110907604-20110920-05 comment=NONE
Finished Control File and SPFILE Autobackup at 20-SEP-11
released channel: c1


Backing up the whole database:

The whole database can be backed up using the below mentioned simple command

RMAN> backup database;

 The above command will back up all data files and control/sp files assuming configure control autobackup is set to on.
In order to make sure that the database has all the online redo log files are also archived at the time of the backup issue the following command at the RMAN prompt
RMAN> SQL "alter system archive log current";
This command will archive the current redo log right after the backup completes

Backing up the archived redo log files:

Use the backup archivelog command to back up archived redo logs. To back up one copy
of each log sequence number for all the archived redo logs, for example, you can issue the
following command:
RMAN> backup archivelog all;

No comments:

Post a Comment