Making Oracle Database Incremental Backup via RMAN

RMAN: Oracle Database Incremental Backup
Андрей Волков

Андрей Волков

Системное, сетевое администрирование +DBA. И немного программист!))  Профиль автора.

RMAN has three separate and distinct incremental backup features:


Table of contents[Show]

With incremental-level backups, RMAN only backs up the blocks that have been modified since a previous backup. Incremental backups can be applied to the entire database, tablespaces, or data files. Incremental-level backups are the most commonly used incremental feature with RMAN.

Incrementally updating backups is a separate feature from incremental-level backups. These backups take image copies of the data files and then use incremental backups to update the image copies. This gives you an efficient way to implement and maintain image copies as part of your backup strategy. You only take the image copy backup once, and then use incremental backups to keep the image copies updated with the most recent transactions.

Block change tracking is another feature designed to speed up the performance of incremental backups. The idea here is that an OS file is used to record which blocks have changed since the last backup. RMAN can use the block change tracking file to quickly identify which blocks need to be backed up when performing incremental backups. This feature can greatly improve the performance of incremental backups.

Taking Incremental-Level Backups

RMAN implements incremental backups through levels. Starting with Oracle 10g, there are only two documented levels of incremental backups: level 0 and level 1. Prior versions of Oracle offer five levels, 0–4. These levels (0–4) are still available but are not specified in the Oracle documentation. You must first take a level 0 incremental backup to establish a baseline, after which you can take a level 1 incremental backup.

Image Note  A full backup backs up the same blocks as a level 0 backup. However, you can’t use a full backup with incremental backups. Furthermore, you have to start an incremental backup strategy with a level 0 backup. If you attempt to take a level 1 backup, and no level 0 exists, RMAN will automatically take a level 0 backup.

Here is an example of taking an incremental level 0 backup:

RMAN> backup incremental level=0 database;

Suppose for the next several backups you want to back up only the blocks that have changed since the last incremental backup. This line of code takes a level 1 backup:

RMAN> backup incremental level=1 database;

There are two different types of incremental backups: differential and cumulative. Which type you use depends on your requirements. Differential backups (the default) are smaller but take more time to recover from. Cumulative backups are larger than differential backups but require less recovery time.

A differential incremental level 1 backup instructs RMAN to back up blocks that have changed since the last level 1 or level 0 backup, whereas a cumulative incremental level 1 backup instructs RMAN to back up blocks that have changed since the last level 0 backup. Cumulative incremental backups, in effect, ignore any level 1 incremental backups.

Image Note  The RMAN incremental level 0 backups are used to restore the data files, whereas the RMAN incremental level 1 backups are used to recover the data files.

When using incremental backups, I almost always use the default, of differential. Usually, I don’t worry about the differences between differential and cumulative backups. If you require cumulative backups, you must specify the key word CUMULATIVE. Here is an example of taking a cumulative level 1 backup:

RMAN> backup incremental level=1 cumulative database;

Here are some examples of taking incremental backups at a more granular level than the database:

RMAN> backup incremental level=0 tablespace sysaux;

RMAN> backup incremental level=1 tablespace sysaux plus archivelog;

RMAN> backup incremental from scn 4343352 datafile 3;

Making Incrementally Updating Backups

The basic idea behind an incrementally updating backup is to create image copies of data files and then use incremental backups to update the image copies. In this manner, you have image copies of your database that are kept somewhat current. This can be an efficient way to combine image copy backups with incremental backups.

To understand how this backup technique works, you’ll need to inspect the commands that perform an incrementally updating backup. The following lines of RMAN code are required to enable this feature:

run{recover copy of database with tag 'incupdate';

backup incremental level 1 for recover of copy with tag 'incupdate' database;}

In the first line a tag is specified (this example uses incupdate). You can use whatever you want for the tag name; the tag name lets RMAN associate the backup files being used each time the commands are run. This code will perform as follows the first time you run the script:

  • RECOVER COPY generates a message saying there’s nothing for it to do.
  • If no image copies exist, the BACKUP INCREMENTAL creates an image copy of the database data files.

You should see messages such as this in the output when the RECOVER COPY and BACKUP INCREMENTAL commands run the first time:

no copy of datafile 1 found to recover

...

no parent backup or copy of datafile 1 found

...

The second time you run the incrementally updating backup, it does as follows:

  • RECOVER COPY again generates a message saying it has nothing to do.
  • BACKUP INCREMENTAL makes an incremental level 1 backup and assigns it the tag name specified; this backup will subsequently be used by the RECOVER COPY command.

The third time you run the incrementally updating backup, it does this:

  • Now that an incremental backup has been created, the RECOVER COPY applies the incremental backup to the image copies.
  • BACKUP INCREMENTAL makes an incremental level 1 backup and assigns it the tag name specified; this backup will subsequently be used by the RECOVER COPY command.

Going forward, each time you run the two lines of code, you will have a regularly repeating backup pattern. If you use image copies for backups, you might consider using an incrementally updating backup strategy, because with it, you avoid creating entire image copies whenever the backup runs. The image copies are updated each time the backup runs with the incremental changes from the previous backup.

Using Block Change Tracking

Block change tracking is the process in which a binary file is used to record changes to database data file blocks. The idea is that incremental backup performance can be improved because RMAN can use the block change tracking file to pinpoint which blocks have changed since the last backup. This saves a great deal of time because otherwise RMAN would have to scan all the blocks that had been backed up to determine if they’d changed since the last backup.

Listed next are the steps for enabling block change tracking:

  1. If not already enabled, set the DB_CREATE_FILE_DEST parameter to a location (that already exists on disk); for example,
    SQL> alter system set db_create_file_dest='/u01/O12C/bct' scope=both;
  2. Enable block change tracking via the ALTER DATABASE command:
    SQL> alter database enable block change tracking;

This example creates a file with an OMF name in the directory specified by DB_CREATE_FILE_DEST. In this example the file created is given this name:

/u01/O12C/bct/O12C/changetracking/o1_mf_8h0wmng1_.chg

You can also enable block change tracking by directly specifying a file name, which does not require that DB_CREATE_FILE_DEST be set; for example,

SQL> alter database enable block change tracking using file '/u01/O12C/bct/btc.bt';

You can verify the details of block change tracking by running the following query:

SQL> select * from v$block_change_tracking;

For space-planning purposes, the size of the block change tracking file is approximately 1/30,000 the size of the total size of the blocks being tracked in the database. Therefore, the size of the block change tracking file is proportional to the size of the database and not to the amount of redo generated.

To disable block change tracking, run this command:

SQL> alter database disable block change tracking;

Image Note  When you disable block change tracking, Oracle will automatically delete the block change tracking file.

Вас заинтересует / Intresting for you:

RMAN: Using Online or Offline ...
RMAN: Using Online or Offline ... 1623 views Андрей Волков Sat, 29 Feb 2020, 10:01:33
RMAN: Specifying the Backup Us...
RMAN: Specifying the Backup Us... 2464 views Андрей Волков Sat, 29 Feb 2020, 10:14:03
RMAN: Checking for Corruption ...
RMAN: Checking for Corruption ... 26913 views Андрей Волков Thu, 30 Sep 2021, 11:57:27
RMAN: Backing UP Oracle Databa...
RMAN: Backing UP Oracle Databa... 912 views Андрей Волков Wed, 29 Sep 2021, 18:27:51
Comments (0)
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Suggested Locations