Using block tracking one can improve performance of the backup time of incremental backup from hours to minutes depending on size of database as it no longer needs to scan blocks in datafiles to find blocks changed it can use the block tracking file to identify changed blocks for incremental backup. Enabling this starts a new background process called Change Tracking Writer (CTWR) which manages this file.
Here are the steps to enable block tracking:
— Note if the file already exists the command will fail unless the REUSE option is used so first check if block tracking is not enabled before overwriting the file.
— if it returns DISABLED it means block tracking is off
SQL> SELECT distinct status from V$BLOCK_CHANGE_TRACKING;
SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE ‘/u04/oradata/TEST/rman_block_tracking.f’;
— indicating block tracking is enabled and the find the block tracking file
SQL> select status, filename from V$BLOCK_CHANGE_TRACKING;
After block tracking file is created you would need to do level 0 backup to ensure the next incremental backup uses the block tracking file.
RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;
The subsequent incremental backup (differential/cumulative) would use the block change tracking file to identify the changes that need to be backed up.
— For differential incremental backup, this will backup blocks since last last level 0 or level 1 which ever is latter.
RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;
— For cumulative incremental backups, this will backup all blocks changed since level 0 backup
RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;
To disable block tracking:
Note: Disabling the block tracking will delete the block tracking file
SQL> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;
SQL> !ls -l /u04/oradata/TEST/rman_block_tracking.f
ls: /u04/oradata/TEST/rman_block_tracking.f: No such file or directory
Shows the process that are using the file, and when RMAN is running it will have handles on the file when running incremental backup.
$ fuser /u04/oradata/TEST/rman_block_tracking.f
oracle 9597302 1 0 13:29:41 – 0:31 ora_ctwr_TEST