Incremental Backups with Block Change Tracking & Recover Copy

I am in Berlin this week for an Administration Workshop II course. Unfortunately, it’s raining right now, so it would be no fun to stroll around the capital. Instead, there is time now for me to post something :-) Two major areas of that course are Performance Tuning and Backup & Recovery.  One interesting feature that we discuss from the latter area is the ability to drastically speed up incremental backups (compared to versions before 10g) and to use these incremental backup for an actualization of level 0 image copies. Let’s look at an example:

SQL> alter database enable block change tracking using file '/home/oracle/bc.ora';

This command brings up the background process Change Tracking Writer (CTWR), that maintains a change tracking file. This file will contain the database block adresses of Oracle Blocks, modified after the next level 0 Full Backup. Because of this file, RMAN no longer has to scan all production datafiles and compare their blocks with the blocks of the level 0 backup in order to determine which blocks have changed. That was a very time consuming process before 10g. Now we will invoke RMAN with the following command:


 RMAN> run {
 recover copy of database with tag 'backrec';
 backup incremental level 1 cumulative copies=1 for recover of copy with tag 'backrec' database;
 }
Starting recover at 04-MAY-09
 using target database control file instead of recovery catalog
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: sid=127 devtype=DISK
 no copy of datafile 1 found to recover
 no copy of datafile 2 found to recover
 no copy of datafile 3 found to recover
 no copy of datafile 4 found to recover
 no copy of datafile 5 found to recover
 no copy of datafile 6 found to recover
 Finished recover at 04-MAY-09
 Starting backup at 04-MAY-09
 using channel ORA_DISK_1
 no parent backup or copy of datafile 1 found
 no parent backup or copy of datafile 3 found
 no parent backup or copy of datafile 5 found
 no parent backup or copy of datafile 2 found
 no parent backup or copy of datafile 6 found
 no parent backup or copy of datafile 4 found
 channel ORA_DISK_1: starting datafile copy
 input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
 output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_4zy6pnsg_.dbf tag=BACKREC recid=14 stamp=685996946
 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
 channel ORA_DISK_1: starting datafile copy
 input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
 output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_sysaux_4zy6qqvp_.dbf tag=BACKREC recid=15 stamp=685996969
 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
 channel ORA_DISK_1: starting datafile copy
 input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
 output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_example_4zy6rk0w_.dbf tag=BACKREC recid=16 stamp=685996982
 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
 channel ORA_DISK_1: starting datafile copy
 input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
 output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_undotbs1_4zy6rr46_.dbf tag=BACKREC recid=17 stamp=685996987
 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
 channel ORA_DISK_1: starting datafile copy
 input datafile fno=00006 name=/u01/app/oracle/oradata/orcl/users02.dbf
 output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_4zy6rv92_.dbf tag=BACKREC recid=18 stamp=685996987
 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
 channel ORA_DISK_1: starting datafile copy
 input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
 output filename=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_4zy6rwc5_.dbf tag=BACKREC recid=19 stamp=685996988
 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
 Finished backup at 04-MAY-09
 Starting Control File and SPFILE Autobackup at 04-MAY-09
 piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_05_04/o1_mf_s_685996989_4zy6rxvx_.bkp comment=NONE
 Finished Control File and SPFILE Autobackup at 04-MAY-09

If you look at the output above, you will bascially see that we did a level 0 Full Backup with Image Copies of all the datafiles. Now let’s modify some blocks in the database:

SQL> update sh.sales set amount_sold=amount_sold*1 where rownum<10000;
9999 rows updated.
SQL> commit;
Commit complete.

Now we run the same RMAN command again:

RMAN> run { recover copy of database with tag 'backrec'; 
            backup incremental level 1 cumulative copies=1 for recover of copy with tag 'backrec' database; }
Starting recover at 04-MAY-09
using channel ORA_DISK_1
 no copy of datafile 1 found to recover
 no copy of datafile 2 found to recover
 no copy of datafile 3 found to recover
 no copy of datafile 4 found to recover
 no copy of datafile 5 found to recover
 no copy of datafile 6 found to recover
 Finished recover at 04-MAY-09
 Starting backup at 04-MAY-09
 using channel ORA_DISK_1
 channel ORA_DISK_1: starting incremental level 1 datafile backupset
 channel ORA_DISK_1: specifying datafile(s) in backupset
 input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
 input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
 input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
 input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
 input datafile fno=00006 name=/u01/app/oracle/oradata/orcl/users02.dbf
 input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
 channel ORA_DISK_1: starting piece 1 at 04-MAY-09
 channel ORA_DISK_1: finished piece 1 at 04-MAY-09
 piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_05_04/o1_mf_nnnd1_TAG20090504T185902_4zy7ppmg_.bkp tag=TAG20090504T185902 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
 Finished backup at 04-MAY-09
 Starting Control File and SPFILE Autobackup at 04-MAY-09
 piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_05_04/o1_mf_s_685997943_4zy7pqr4_.bkp comment=NONE
 Finished Control File and SPFILE Autobackup at 04-MAY-09

Please notice the very short time it took RMAN to backup the (few) modified blocks during the incremental backup. Although this database is tiny of course, that would have taken a much longer time without block change tracking. The effect is way more dramatic in databases of more realistic sizes. Again we modify some blocks as before. After the third call of the command, we will see now always the following behavior:


RMAN> run {recover copy of database with tag 'backrec';
backup incremental level 1 cumulative copies=1 for recover of copy with tag 'backrec' database;}

Starting recover at 04-MAY-09

using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy fno=00001 name=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_system_4zy6pnsg_.dbf
recovering datafile copy fno=00002 name=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_undotbs1_4zy6rr46_.dbf
recovering datafile copy fno=00003 name=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_sysaux_4zy6qqvp_.dbf
recovering datafile copy fno=00004 name=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_4zy6rwc5_.dbf
recovering datafile copy fno=00005 name=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_example_4zy6rk0w_.dbf
recovering datafile copy fno=00006 name=/u01/app/oracle/flash_recovery_area/ORCL/datafile/o1_mf_users_4zy6rv92_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_05_04/o1_mf_nnnd1_TAG20090504T185902_4zy7ppmg_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_05_04/o1_mf_nnnd1_TAG20090504T185902_4zy7ppmg_.bkp tag=TAG20090504T185902
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished recover at 04-MAY-09
Starting backup at 04-MAY-09
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/orcl/users02.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-MAY-09
channel ORA_DISK_1: finished piece 1 at 04-MAY-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2009_05_04/o1_mf_nnnd1_TAG20090504T190410_4zy80cd8_.bkp tag=TAG20090504T190410 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 04-MAY-09
Starting Control File and SPFILE Autobackup at 04-MAY-09
piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2009_05_04/o1_mf_s_685998253_4zy80g2q_.bkp comment=NONE

First RMAN  actualizes the image copies of the datafiles in the recover copy section of the command. Then again a very fast incremental backup is done. In this fashion, we always get a quite fast backup and have our backup very close (in terms of time) to the production datafiles, so that a restore & recovery can be done fairly fast also. This picture illustrates the Recovery Area as well as the Recommended Backup Strategy that you have seen at work in this posting:

Recovery Area & Recommended Backup Strategy for Oracle DatabasesConclusion: Incremental Backups can be taken very fast with the 10g New Feature Block Change Tracking. Together with Image Copies and the 11g New Feature Recover Copy this is the Recommended Backup Strategy for Oracle Databases. What is your reason why it is not implemented at your site?

About these ads

, , ,

  1. #1 by Anand on July 24, 2009 - 01:10

    Something new i learned.Thank you.

    Regards,
    Anand

  2. #2 by prince oberoi on April 26, 2013 - 04:24

    Well defined..

  3. #3 by Tuba Altun on April 26, 2013 - 08:37

    Thanks a lot for your sharing.

  4. #4 by Uwe Hesse on April 26, 2013 - 18:07

    Thank YOU guys for taking the time to leave a nice feedback :-)

  5. #5 by Krishna on May 5, 2013 - 16:17

    Thank you for sharing use full information with us.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 2,683 other followers

%d bloggers like this: