Do you know how your Oracle RMAN backup works?

Do you know how your Oracle RMAN backup works?

Recovery Manager or better known as RMAN, is an Oracle client utility that is installed with the Enterprise or Standard edition, you can also find it with the Admin option when installing the Oracle Client.

In it’s most basic form, the RMAN client connects, an it needs to be with a “sysdba” privileged user, to the database that is being backed up, called a TARGET database, this client, is an executable that is normally found in $ORACLE_HOME/bin.

By being a client side utility, it allows you to use one RMAN executable version to backup current and previous versions of the Oracle Database, there are some restrictions to this though, which can be verified in MOS document RMAN Compatibility Matrix [ID 73431.1].

This RMAN executable uses a file called recover.bsq , this file is located in $ORACLE_HOME/rdbms/admin , basically what the executable does, is to interpret the commands you give it , direct server sessions to execute those commands, and record its activity in the TARGET database control file that is being backed up.

There are two main SYS packages that do the work of backup and recovery, which are DBMS_RCVMAN, this has the procedures which list your database incarnations, the set until time recovery window, list your backups, to name a few,  and DBMS_BACKUP_RESTORE , which as you might have guessed is the one who does the backup and recovery operations, like create the control file snapshot , backup the datafiles , backup the spfile to name some.

As mentioned above, the way that the RMAN client directs the server sessions to execute the commands are through channels , a channel represents one stream of data to a device, and corresponds to one database server session. The channel reads data into PGA memory, processes it, and writes it to the output device.

The work of each channel, whether of type disk or System Backup Tape (SBT), is subdivided into the following distinct phases:
  1. Read Phase
    A channel reads blocks from disk into input I/O buffers. The allocation of these buffers depend on the number of datafiles being read simultaneously from disk and written to the same backup piece. One way to control the numbers of files is the backup parameter FILESPERSET
  2. Copy Phase
    A channel copies blocks from input buffers to output buffers and performs additional processing on the blocks, like the validation of the data blocks, as it verifies that it’s not backing up corrupt data blocks, it’s also the phase where it does the binary compression and the backup encryption
  3. Write Phase
    A channel writes the blocks from output buffers to storage media. The write phase can be either to SBT or to disk, and these are mutually exclusive, meaning you write to one or the other, not both. 
As you can see by the phases above, and what distinguishes RMAN from any other method, is that the backup is at the block level, as to the user managed backups, it brings great advantages , as it wont have to backup empty blocks.
One great way to see how your backup works, is to do a trace, here you will see everything that has been mentioned above

oracle@servidor1.oracleenespanol.blogspot.com [TESTDB] /home/oracle/bin
oracle $ rman target / debug trace=backup.trc

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Dec 13 09:42:01 2012

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

RMAN-06005: connected to target database: TESTDB (DBID=2580834116)

RMAN> backup database plus archivelog;

Once the backup finishes, you can search the trace file and see what it is actually doing, here is an example of the RCVMAN fetching the incarnation information:

      DBGRCVMAN: Fetching incarnation records
DBGRCVMAN: incarnation record id=0
DBGRCVMAN: icprs=0,icprc=
DBGRCVMAN: icrls=1,icrlc=Oct 24 2012 09:26:28
DBGRCVMAN: icrlc_i=797505988
DBGRCVMAN: icpinc=0
DBGRCVMAN: icflg=CURRENT
DBGRCVMAN: number of incarnation=1
DBGRCVMAN: canApplyAnyRedo is set to TRUE
DBGRCVMAN: canConvert_Cf is set to TRUE
DBGRCVMAN: canHandleTransportableTbs is set to TRUE

Below you can see the RPC calls being done by DBMS_BACKUP_RESTORE and the IO information  by the  INPUT buffers and the OUTPUT buffers.

DBGRPC:          krmxr - channel ORA_DISK_1 calling peicnt
DBGRPC: krmxrpc - channel ORA_DISK_1 kpurpc2 err=0 db=target proc=SYS.DBMS_BACKUP_RESTORE.BACKUPPIECECREATE excl: 0
DBGRPC: krmxrpc - channel ORA_DISK_1 kpurpc2 err=0 db=target proc=SYS.DBMS_BACKUP_RESTORE.PIECECONTEXTGETNUMBER excl: 0
DBGRPC: krmxrpc - channel ORA_DISK_1 kpurpc2 err=0 db=target proc=SYS.DBMS_BACKUP_RESTORE.BACKUPCANCEL excl: 0
DBGIO: Type %Comp Blocks Tot Blocks Blksize ElpTime(s) IO Rt(b/s) Name [09:43:14.946] (krmkqio)
DBGIO: ---- ----- ---------- ---------- ---------- ---------- ---------- ----- [09:43:14.946] (krmkqio)
DBGIO: IN 3.6 2304 64000 8192 0 0 /mount/u01/oracle/TESTDB/data/undotbs1_01.dbf [09:43:14.946] (krmkqio)
DBGIO: IN 90.0 11520 12800 8192 0 0 /mount/u01/oracle/TESTDB/data/sysaux01.dbf [09:43:14.947] (krmkqio)
DBGIO: IN 51.9 33216 64000 8192 2 136052736 /mount/u01/oracle/TESTDB/data/system01.dbf [09:43:14.947] (krmkqio)
DBGIO: IN 59.7 38208 64000 8192 2 156499968 /mount/u01/oracle/TESTDB/data/users01.dbf [09:43:14.947] (krmkqio)
DBGIO: OUT 39224 8192 2 160661504 /mount/oracle/copy01/flash_recovery_area/TESTDB/TESTDB/backupset/2012_12_13/o1_mf_nnndf_TAG20121213T094259_8dmtcn0w_.bkp [09:43:14.947] (krmkqio)
DBGIO: AGG 85248 8192 2 349175808 [09:43:14.947] (krmkqio)
DBGMISC: ENTERED krmzlog [09:43:14.948]
RMAN-08044: channel ORA_DISK_1: finished piece 1 at Dec 13 2012 09:43:14

I hope this helps you understand more how your backup works, and this is just the super condensed version, there is a lot of information missing, like how RMAN allocates the IN and OUT buffers, or how the disk writes are differentiated from the SBT writes, so go out there and see it yourself.

Also some of the information for this entry came from these two great books:

Oracle RMAN 11g Backup and Recovery

Oracle® Database Backup and Recovery User’s Guide 11g Release 2 (11.2)

Rene Antunez
[email protected]
No Comments

Sorry, the comment form is closed at this time.