Rman (four) incremental backup for Oracle learning

Source: Internet
Author: User

Rman not only can make the database, data files and other full-scale backup, but also can do incremental backup. Incremental backups have two major advantages:

    • Reduce the time of database recovery.

      Database recovery uses archived logs to continually apply archived logs to restore the database to the latest (or specified state). However, an incremental backup backs up only the modified blocks and, when performing the recovery, overwrites the changed chunks in the data file directly with the backed-up data blocks.

    • Reduce backup time

      Incremental backups only need to back up the data blocks that have been modified, and the backup time and backup storage space are reduced accordingly.


The premise of doing an incremental backup is that a baseline backup is required, and all the increments are for this benchmark. Otherwise, incremental backups do not have to be discussed.

Incremental backups are specified using the incremental level=integer keyword. An integer can be any integer from 0 to 4.

A level 0 backup must be used as the underlying backup of the incremental policy. A level 0 incremental backup is identical in content to a full backup, but unlike a full backup, a level 0 backup is considered part of the incremental strategy. If a level 0 backup does not exist when you run a 1-level or higher backup, RMAN automatically makes a 0-level backup.

There are two ways of incremental backups:

    • Differential incremental backup

N-level backup, which backs up all blocks that have changed since the most recent n-level or lower-level backup.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/70/9C/wKiom1W57jiTFpLiAADx2SL2yvQ188.jpg "title=" differential backup. PNG "alt=" Wkiom1w57jitfpliaadx2sl2yvq188.jpg "/>

    • Cumulative Incremental backup

N-level backup that contains all the blocks that have been changed since the last n-1 or lower level backup.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/70/99/wKioL1W58O3R86GpAAD-49pjDX4461.jpg "title=" Cumulative incremental backup . PNG "alt=" Wkiol1w58o3r86gpaad-49pjdx4461.jpg "/>

Cumulative incremental backups Use the cumulative keyword, such as:

BACKUP INCREMENTAL Level 2 cumulative DATABASE;

Let's demonstrate the incremental backup

rman> backup incremental level =0 database; Starting backup at 2015/07/08 15:16:44using channel ora_disk_1channel ora_ Disk_1: starting incremental level 0 datafile backup setchannel ora_ Disk_1: specifying datafile (s)  in backup setinput datafile file number =00001 name=/u01/app/oracle/oradata/devdb/system01.dbfinput datafile file number=00002  name=/u01/app/oracle/oradata/devdb/sysaux01.dbfinput datafile file number=00005 name =/u01/app/oracle/oradata/devdb/example01.dbfinput datafile file number=00003 name=/u01/app /oracle/oradata/devdb/undotbs01.dbfinput datafile file number=00006 name=/u01/app/oracle/ Oradata/devdb/idx01.dbfinput datafile file number=00004 name=/u01/app/oracle/oradata/devdb /users01.dbfchannel ora_disk_1: starting pIece 1 at 2015/07/08 15:16:44channel ora_disk_1: finished piece 1  at 2015/07/08 15:17:59piece handle=/u01/app/oracle/fast_recovery_area/devdb/backupset/ 2015_07_08/o1_mf_nnnd0_tag20150708t151644_bssmlwog_.bkp tag=tag20150708t151644 comment=nonechannel  ORA_DISK_1: backup set complete, elapsed time: 00:01:15Finished  backup at 2015/07/08 15:17:59starting control file and spfile  autobackup at 2015/07/08 15:17:59piece handle=/u01/app/oracle/fast_recovery_area/devdb/ autobackup/2015_07_08/o1_mf_s_884531879_bssmo893_.bkp comment=nonefinished control file  and spfile autobackup at 2015/07/08 15:18:00

Here we make some changes to the library

sql> INSERT INTO emp_new select * from emp_new;14 rows created. sql>/28 rows created. sql>/56 rows created. sql>/112 rows created. sql>/224 rows created. sql>/448 rows created.

Then perform a full-Library level 1 backup

rman> backup incremental level=1 database; Starting backup at 2015/07/08 15:24:38using channel ora_disk_1channel ora_ Disk_1: starting incremental level 1 datafile backup setchannel ora_ Disk_1: specifying datafile (s)  in backup setinput datafile file number =00001 name=/u01/app/oracle/oradata/devdb/system01.dbfinput datafile file number=00002  name=/u01/app/oracle/oradata/devdb/sysaux01.dbfinput datafile file number=00005 name =/u01/app/oracle/oradata/devdb/example01.dbfinput datafile file number=00003 name=/u01/app /oracle/oradata/devdb/undotbs01.dbfinput datafile file number=00006 name=/u01/app/oracle/ Oradata/devdb/idx01.dbfinput datafile file number=00004 name=/u01/app/oracle/oradata/devdb /users01.dbfchannel ora_disk_1: starting piece&nBsp;1 at 2015/07/08 15:24:39channel ora_disk_1: finished piece 1 at  2015/07/08 15:25:34piece handle=/u01/app/oracle/fast_recovery_area/devdb/backupset/2015_07_08/ O1_mf_nnnd1_tag20150708t152439_bssn1qjd_.bkp tag=tag20150708t152439 comment=nonechannel ora_ Disk_1: backup set complete, elapsed time: 00:00:55finished backup at  2015/07/08 15:25:34starting control file and spfile autobackup at  2015/07/08 15:25:34piece handle=/u01/app/oracle/fast_recovery_area/devdb/autobackup/2015_07_08 /o1_mf_s_884532334_bssn3h9x_.bkp comment=nonefinished control file and spfile  Autobackup at 2015/07/08 15:25:35

Let's take a look at the size of the incremental backup set file

11gdg-> ll-htotal 1.1g-rw-r-----1 Oracle asmadmin 1.1G Jul 8 15:17 o1_mf_nnnd0_tag20150708t151644_bssmlwog_.bkp-rw-r -----1 Oracle Asmadmin 488K Jul 8 15:25 O1_MF_NNND1_TAG20150708T152439_BSSN1QJD_.BKP

You may have a question about the concept of incremental backup. How does Rman know which blocks have been modified since the last backup? The SCN number is recorded in each data block in the data file, and during an incremental backup, Rman reads the SCN of each block in the data file, and the checkpoint SCN comparison of the parent incremental backup set. If the SCN of the block is greater than the checkpoint SCN, then this block can be determined to be modified.

What are the drawbacks of implementing an incremental backup? Although incremental backups are, all blocks of the database need to be scanned for backup. This means that incremental backups take less time than full backups. Only the resulting backup set is smaller.

In 10g, Rman does incremental backup no longer needs to scan the entire data file, 10g introduced new features block change tracking. The block change tracking process records the changes in the data block since the last backup and records the information in the trace file. Rman uses this file to determine the change data that needs to be backed up in an incremental backup. This greatly facilitates backup performance, and Rman can no longer scan the entire file to find change data.

Block change tracking implements the following functions:

    • Maintains a record that records the data blocks that have been modified since the last backup.

    • When the redo is generated, the record is written to the file.

    • When an incremental backup is performed, the file is automatically accessed to speed up the backup.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/70/9B/wKioL1W6EpGSPqTOAADcIOVbGsw098.jpg "title=" block Change tracking. PNG "alt=" Wkiol1w6epgspqtoaadciovbgsw098.jpg "/>

Turn on block change tracking

Sql> ALTER DATABASE enable block change tracking using file '/u01/app/oracle/fast_recovery_area/tracking.log ';D Atabase altered.

Let's revise the data.

sql> INSERT INTO emp_new select * from emp_new;896 rows created. Sql> commit;

See Tracking file

[[email protected] fast_recovery_area]# ll-h tracking.log-rw-r-----1 Oracle asmadmin 12M Jul 8 17:24 Tracking.log

According to reason, Emp_new 896 data, should not have so big tracking file. Let's add some data to the table to see if there are any changes to the tracking file.

sql> INSERT INTO emp_new select * from emp_new;1792 rows created. sql>/3584 rows created. sql>/7168 rows created. sql>/14336 rows created. sql>/28672 rows created. sql>/57344 rows created. Sql> commit; Commit complete.

Review the Tracking.log file size again.

[[email protected] fast_recovery_area]# ll-h tracking.log-rw-r-----1 Oracle asmadmin 12M Jul 8 17:27 Tracking.log

Size does not change.

View v$block_change_tracking allows you to view details of the tracking file

sql> col filename for a50sql> set linesize-pagesize 800sql> select * from v$block_change_tracking; STATUS FILENAME BYTES----------------------------------------------------------------------Enabled/u01/app/oracl E/fast_recovery_area/tracking.log11599872sql>

Let's do one more level 1 backup.

rman> backup incremental level=1 database; Starting backup at 2015/07/08 17:39:38using channel ora_disk_1channel ora_ Disk_1: starting incremental level 1 datafile backup setchannel ora_ Disk_1: specifying datafile (s)  in backup setinput datafile file number =00001 name=/u01/app/oracle/oradata/devdb/system01.dbfinput datafile file number=00002  name=/u01/app/oracle/oradata/devdb/sysaux01.dbfinput datafile file number=00005 name =/u01/app/oracle/oradata/devdb/example01.dbfinput datafile file number=00003 name=/u01/app /oracle/oradata/devdb/undotbs01.dbfinput datafile file number=00004 name=/u01/app/oracle/ oradata/devdb/users01.dbfinput datafile file number=00006 name=/u01/app/oracle/oradata/ Devdb/idx01.dbfchannel ora_disk_1: starting piece&nBsp;1 at 2015/07/08 17:39:38channel ora_disk_1: finished piece 1 at  2015/07/08 17:41:33piece handle=/u01/app/oracle/fast_recovery_area/devdb/backupset/2015_07_08/ O1_mf_nnnd1_tag20150708t173938_bssvytyy_.bkp tag=tag20150708t173938 comment=nonechannel ora_ Disk_1: backup set complete, elapsed time: 00:01:55finished backup at  2015/07/08 17:41:33starting control file and spfile autobackup at  2015/07/08 17:41:34piece handle=/u01/app/oracle/fast_recovery_area/devdb/autobackup/2015_07_08 /o1_mf_s_884540494_bssw2gsv_.bkp comment=nonefinished control file and spfile  Autobackup at 2015/07/08 17:41:35

This backup is not used to block change tracking. Because the last backup of Level 1 was done before we started the tracking feature. Oracle was unable to determine whether a block was modified between the backup to boot tracking.

Let's make some data changes.

Sql> conn scott/tigerconnected.sql> INSERT INTO emp_new select * from emp_new;114688 rows created. Sql> commit; Commit complete.

Let's do another backup.

rman> backup incremental level=1 database; Starting backup at 2015/07/08 17:45:08using channel ora_disk_1channel ora_ Disk_1: starting incremental level 1 datafile backup setchannel ora_ Disk_1: specifying datafile (s)  in backup setinput datafile file number =00001 name=/u01/app/oracle/oradata/devdb/system01.dbfinput datafile file number=00002  name=/u01/app/oracle/oradata/devdb/sysaux01.dbfinput datafile file number=00005 name =/u01/app/oracle/oradata/devdb/example01.dbfinput datafile file number=00003 name=/u01/app /oracle/oradata/devdb/undotbs01.dbfinput datafile file number=00004 name=/u01/app/oracle/ oradata/devdb/users01.dbfinput datafile file number=00006 name=/u01/app/oracle/oradata/ Devdb/idx01.dbfchannel ora_disk_1: starting piece&nBsp;1 at 2015/07/08 17:45:09channel ora_disk_1: finished piece 1 at  2015/07/08 17:45:16piece handle=/u01/app/oracle/fast_recovery_area/devdb/backupset/2015_07_08/ O1_mf_nnnd1_tag20150708t174508_bssw99qw_.bkp tag=tag20150708t174508 comment=nonechannel ora_ Disk_1: backup set complete, elapsed time: 00:00:07finished backup at  2015/07/08 17:45:16starting control file and spfile autobackup at  2015/07/08 17:45:16piece handle=/u01/app/oracle/fast_recovery_area/devdb/autobackup/2015_07_08 /o1_mf_s_884540716_bssw9dhq_.bkp comment=nonefinished control file and spfile  Autobackup at 2015/07/08 17:45:17

This backup takes only 7 seconds to complete, about 1 minutes earlier. It can be seen that the use of block change tracking technology greatly accelerates the speed of incremental backups.

This article is from the "Ding Dong" blog, please be sure to keep this source http://lqding.blog.51cto.com/9123978/1680253

Rman (four) incremental backup for Oracle learning

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.