[20160710]backup archivelog all not backed up 1 times.txt
--我们生产系统archivelog总是保留1个月的时间不删除.这样在日常备份中为了避免重复备份archivelog,就要注意备份N次的
--archivelog,就不需要再备份.
--在rman脚本中写入:
backup archivelog all not backed up 1 times format '/home/oracle/backup/arch_%U';
--次数可以根据自己备份的需要修改,我这里选择1.这样后续的备份仅仅备份没有备份的archivelog.
--如果次数2,就仅仅备份已经备份1次以及还没有备份的archivelog.减少备份的空间占用.
--在测试环境测试看看;
1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
RMAN> delete archivelog all completed before 'sysdate-1';
RMAN> list archivelog all ;
List of Archived Log Copies for database with db_unique_name BOOK
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - -------------------
204 1 343 A 2016-07-10 08:24:16
Name: /u01/app/oracle/archivelog/book/1_343_907434361.dbf
205 1 344 A 2016-07-10 13:10:21
Name: /u01/app/oracle/archivelog/book/1_344_907434361.dbf
206 1 345 A 2016-07-10 22:04:43
Name: /u01/app/oracle/archivelog/book/1_345_907434361.dbf
--保留1天的archivelog。为了测试需要,不要备份这个多archivelog。
2.备份第1次:
RMAN> backup archivelog all not backed up 1 times format '/home/oracle/backup/arch_%U';
Starting backup at 2016-07-11 08:40:09
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=343 RECID=204 STAMP=916837821
input archived log thread=1 sequence=344 RECID=205 STAMP=916869884
channel ORA_DISK_1: starting piece 1 at 2016-07-11 08:40:09
channel ORA_DISK_2: starting archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
input archived log thread=1 sequence=345 RECID=206 STAMP=916907094
input archived log thread=1 sequence=346 RECID=207 STAMP=916908009
channel ORA_DISK_2: starting piece 1 at 2016-07-11 08:40:09
channel ORA_DISK_1: finished piece 1 at 2016-07-11 08:40:10
piece handle=/home/oracle/backup/arch_47radpv9_1_1 tag=TAG20160711T084009 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_2: finished piece 1 at 2016-07-11 08:40:10
piece handle=/home/oracle/backup/arch_48radpv9_1_1 tag=TAG20160711T084009 comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-07-11 08:40:10
Starting Control File and SPFILE Autobackup at 2016-07-11 08:40:10
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2016_07_11/o1_mf_s_916908010_cr5tqbwl_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2016-07-11 08:40:11
RMAN> list archivelog all ;
List of Archived Log Copies for database with db_unique_name BOOK
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - -------------------
204 1 343 A 2016-07-10 08:24:16
Name: /u01/app/oracle/archivelog/book/1_343_907434361.dbf
205 1 344 A 2016-07-10 13:10:21
Name: /u01/app/oracle/archivelog/book/1_344_907434361.dbf
206 1 345 A 2016-07-10 22:04:43
Name: /u01/app/oracle/archivelog/book/1_345_907434361.dbf
207 1 346 A 2016-07-11 08:24:54
Name: /u01/app/oracle/archivelog/book/1_346_907434361.dbf
--备份到seq=346,也就是做archivelog备份时,oracle切换一个archivelog。
3.备份第2次:
RMAN> backup archivelog all not backed up 1 times format '/home/oracle/backup/arch_%U';
Starting backup at 2016-07-11 08:41:56
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
skipping archived logs of thread 1 from sequence 343 to 346; already backed up
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=347 RECID=208 STAMP=916908116
channel ORA_DISK_1: starting piece 1 at 2016-07-11 08:41:56
channel ORA_DISK_1: finished piece 1 at 2016-07-11 08:41:57
piece handle=/home/oracle/backup/arch_4aradq2k_1_1 tag=TAG20160711T084156 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-07-11 08:41:57
Starting Control File and SPFILE Autobackup at 2016-07-11 08:41:57
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2016_07_11/o1_mf_s_916908117_cr5ttoy9_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2016-07-11 08:41:58
--//注意看~,前面的from sequence 343 to 346被跳过,仅仅备份seq =347.
RMAN> list archivelog all ;
List of Archived Log Copies for database with db_unique_name BOOK
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - -------------------
204 1 343 A 2016-07-10 08:24:16
Name: /u01/app/oracle/archivelog/book/1_343_907434361.dbf
205 1 344 A 2016-07-10 13:10:21
Name: /u01/app/oracle/archivelog/book/1_344_907434361.dbf
206 1 345 A 2016-07-10 22:04:43
Name: /u01/app/oracle/archivelog/book/1_345_907434361.dbf
207 1 346 A 2016-07-11 08:24:54
Name: /u01/app/oracle/archivelog/book/1_346_907434361.dbf
208 1 347 A 2016-07-11 08:40:09
Name: /u01/app/oracle/archivelog/book/1_347_907434361.dbf