在rman增量备份中,有差异增量和累积增量的概念
1、概念
差异增量:是备份上级及同级备份以来所有变化的数据块,差异增量是默认增量备份方式
累积增量:是备份上级备份以来所有变化的块
因为累积增量是备份上级备份以来所有变化的数据块,所以累积增量需要更多的备份时间,同时需要较小的恢复时间;而差异增量正好相反,它可以备份同级备份以来变化的数据块。所以会减少备份时间,但需要更多的恢复时间.在oracle 9中增量备份需要通过扫描整个数据库的数据块才能知道哪些数据块发生了变化,这是一个代价很大,时间很长的过程,而且由于增量备份形成多个不同的备份集,使恢复变得更加不可靠,所以增量备份在版本9中仍然不被推荐使用;在10g中,增量备份作了很大的改进,不需要再扫描所有数据块就能得知哪些数据块发生变化,从而大大提升备份效率。但这些却以牺牲磁盘i/o为代价,所以在oltp事务系统中还得衡量是否愿意以i/o为代价来保证安全及高可用性。10g还支持增量合并,增量备份可支持7级增量。
2、备份策略及恢复
以rman多级增量备份来作为备份策略例子:
增量备份都需要一个0级备份来作为基础,0级备份与全备份的区别在于0级可以用来增量恢复,而全备份则不可以。
备份命令如下:
零级备份
[oracle@sql ~]$ rman target / 本地登录RMAN
RMAN> backup incremental level 0 database format='/home/oracle/db_bak/%u';
(level=0 0级别为全库备份 %u生成唯一一个文件名。增量备份第一备份要为全库备份)。
Starting backup at 13-DEC-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/app/oradata/TEST/system01.dbf
input datafile fno=00003 name=/oracle/app/oradata/TEST/sysaux01.dbf
input datafile fno=00002 name=/oracle/app/oradata/TEST/undotbs01.dbf
input datafile fno=00005 name=/oracle/app/oradata/TEST/tbs_recover.dbf
input datafile fno=00004 name=/oracle/app/oradata/TEST/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-DEC-12
channel ORA_DISK_1: finished piece 1 at 13-DEC-12
piece handle=/home/oracle/db_bak/1cnspjub tag=TAG20121213T202131 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 13-DEC-12
channel ORA_DISK_1: finished piece 1 at 13-DEC-12
piece handle=/home/oracle/db_bak/1dnspk0c tag=TAG20121213T202131 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 13-DEC-12
创建一条数据
SQL> create table abc as select * from dba_objects;
Table created.
SQL> insert into abc select * from abc;
49752 rows created.
SQL> select count(*) from abc;
COUNT(*)
----------
99504
进行差异增量备份
RMAN> backup INCREMENTAL LEVEL 1 DATABASE format='/home/oracle/db_bak/%u';
Starting backup at 13-DEC-12
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=/oracle/app/oradata/TEST/system01.dbf
input datafile fno=00003 name=/oracle/app/oradata/TEST/sysaux01.dbf
input datafile fno=00002 name=/oracle/app/oradata/TEST/undotbs01.dbf
input datafile fno=00005 name=/oracle/app/oradata/TEST/tbs_recover.dbf
input datafile fno=00004 name=/oracle/app/oradata/TEST/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-DEC-12
channel ORA_DISK_1: finished piece 1 at 13-DEC-12
piece handle=/home/oracle/db_bak/1enspk7k tag=TAG20121213T202628 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 13-DEC-12
channel ORA_DISK_1: finished piece 1 at 13-DEC-12
piece handle=/home/oracle/db_bak/1fnspk91 tag=TAG20121213T202628 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 13-DEC-12
查看增量备份后的数据和全库备份的数据量的对比
[oracle@sql db_bak]$ ll
total 577472
-rw-r----- 1 oracle oinstall 564551680 Dec 13 20:22 1cnspjub
-rw-r----- 1 oracle oinstall 7143424 Dec 13 20:22 1dnspk0c
-rw-r----- 1 oracle oinstall 11894784 Dec 13 20:27 1enspk7k
-rw-r----- 1 oracle oinstall 7143424 Dec 13 20:27 1fnspk91
进行累计增量备份
插入相同的数据量
SQL> create table nba as select * from abc;
Table created.
SQL> select count(*) from nba;
COUNT(*)
----------
99504
RMAN> backup INCREMENTAL LEVEL 1 DATABASE format='/home/oracle/db_bak/%u';
Starting backup at 13-DEC-12
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=/oracle/app/oradata/TEST/system01.dbf
input datafile fno=00003 name=/oracle/app/oradata/TEST/sysaux01.dbf
input datafile fno=00002 name=/oracle/app/oradata/TEST/undotbs01.dbf
input datafile fno=00005 name=/oracle/app/oradata/TEST/tbs_recover.dbf
input datafile fno=00004 name=/oracle/app/oradata/TEST/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-DEC-12
channel ORA_DISK_1: finished piece 1 at 13-DEC-12
piece handle=/home/oracle/db_bak/1gnspknb tag=TAG20121213T203451 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 13-DEC-12
channel ORA_DISK_1: finished piece 1 at 13-DEC-12
piece handle=/home/oracle/db_bak/1hnspkoo tag=TAG20121213T203451 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 13-DEC-12
查看数据大小
[oracle@sql db_bak]$ ll
total 601236
-rw-r----- 1 oracle oinstall 564551680 Dec 13 20:22 1cnspjub
-rw-r----- 1 oracle oinstall 7143424 Dec 13 20:22 1dnspk0c
-rw-r----- 1 oracle oinstall 11894784 Dec 13 20:27 1enspk7k
-rw-r----- 1 oracle oinstall 7143424 Dec 13 20:27 1fnspk91
-rw-r----- 1 oracle oinstall 17154048 Dec 13 20:35 1gnspknb
-rw-r----- 1 oracle oinstall 7143424 Dec 13 20:35 1hnspkoo
二者之间的差异 呵呵 明白了吧!