ITPub博客

首页 > 数据库 > Oracle > rman备份,增量备份时,通过tag指定,所参照的0级备份

rman备份,增量备份时,通过tag指定,所参照的0级备份

原创 Oracle 作者:BogengWang 时间:2015-10-10 09:52:15 0 删除 编辑

今天孙姐姐,问我这样一个问题:
请教一个rman增量备份的问题。比如,每个周日做一个level0备份,每天做增量备份。然后,在每个月末在做一次增量备份,要求这个增量备份是以这个月第一个周日的level0为基本备份。这样能实现吗?

这个......我也不知道啊,查查文档,发现一段语法,在Oracle? Database Backup and Recovery Reference

点击(此处)折叠或打开

  1. FOR RECOVER OF TAG tag_name
  2. For example, the BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF TAG wholedb ARCHIVELOG ALL command backs up all archived redo log files needed to recover the level 0 incremental backup tagged wholedb.

看着,是可以通过指定一个tag,来选择增量备份时,参照哪个0级备份

随后,在这段语法后面找到一个example

点击(此处)折叠或打开

  1. Example 2-20 Scripting Incrementally Updated Backups
  2. By incrementally updating backups, you can avoid the overhead of making full image copy backups of data files, while also minimizing media recovery time. For example, if you run a daily backup script, then you never have more than one day of redo to apply for media recovery.
  3. Assume you run the following script daily. On first execution, the script creates an image copy backup of the database on disk with the specified tag. On second execution, the script creates a level 1 differential incremental backup of the database. On every subsequent execution, RMAN applies the level 1 incremental backup to the data file copy and then makes a new level 1 backup.
  4. RUN
  5. {
  6. RECOVER COPY OF DATABASE
  7. WITH TAG 'incr_update';
  8. BACKUP
  9. INCREMENTAL LEVEL 1
  10. FOR RECOVER OF COPY WITH TAG 'incr_update'
  11. DATABASE;
  12. }

参照以上的例子,我在虚拟机上试了一下
先生成一个0级的,tag是wbg的备份

点击(此处)折叠或打开

  1. RMAN> backup INCREMENTAL LEVEL 0 tag 'wbg' format '/home/oracle/%U' database ;
  2. Starting backup at 09-OCT-15
  3. using channel ORA_DISK_1
  4. channel ORA_DISK_1: starting incremental level 0 datafile backup set
  5. channel ORA_DISK_1: specifying datafile(s) in backup set
  6. input datafile file number=00002 name=+DATA/orcl/datafile/sysaux.257.891365639
  7. input datafile file number=00001 name=+DATA/orcl/datafile/system.256.891365639
  8. input datafile file number=00005 name=+DATA/orcl/datafile/example.266.891365749
  9. input datafile file number=00003 name=+DATA/orcl/datafile/undotbs1.258.891365639
  10. input datafile file number=00006 name=+DATA/orcl/datafile/undotbs2.267.891365925
  11. input datafile file number=00004 name=+DATA/orcl/datafile/users.259.891365639
  12. channel ORA_DISK_1: starting piece 1 at 09-OCT-15
  13. channel ORA_DISK_1: finished piece 1 at 09-OCT-15
  14. piece handle=/home/oracle/0eqj9jbc_1_1 tag=WBG comment=NONE
  15. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
  16. channel ORA_DISK_1: starting incremental level 0 datafile backup set
  17. channel ORA_DISK_1: specifying datafile(s) in backup set
  18. including current control file in backup set
  19. including current SPFILE in backup set
  20. channel ORA_DISK_1: starting piece 1 at 09-OCT-15
  21. channel ORA_DISK_1: finished piece 1 at 09-OCT-15
  22. piece handle=/home/oracle/0fqj9jbr_1_1 tag=WBG comment=NONE
  23. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
  24. Finished backup at 09-OCT-15

然后,参照tag为wbg的备份,生成一个1级备份

点击(此处)折叠或打开

  1. RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF TAG wbg DATABASE;
  2. Starting backup at 09-OCT-15
  3. using channel ORA_DISK_1
  4. channel ORA_DISK_1: starting incremental level 1 datafile backup set
  5. channel ORA_DISK_1: specifying datafile(s) in backup set
  6. input datafile file number=00002 name=+DATA/orcl/datafile/sysaux.257.891365639
  7. input datafile file number=00001 name=+DATA/orcl/datafile/system.256.891365639
  8. input datafile file number=00005 name=+DATA/orcl/datafile/example.266.891365749
  9. input datafile file number=00003 name=+DATA/orcl/datafile/undotbs1.258.891365639
  10. input datafile file number=00006 name=+DATA/orcl/datafile/undotbs2.267.891365925
  11. input datafile file number=00004 name=+DATA/orcl/datafile/users.259.891365639
  12. channel ORA_DISK_1: starting piece 1 at 09-OCT-15
  13. channel ORA_DISK_1: finished piece 1 at 09-OCT-15
  14. piece handle=+ARCH/orcl/backupset/2015_10_09/nnndn1_wbg_0.314.892653565 tag=WBG comment=NONE
  15. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
  16. channel ORA_DISK_1: starting incremental level 1 datafile backup set
  17. channel ORA_DISK_1: specifying datafile(s) in backup set
  18. including current control file in backup set
  19. including current SPFILE in backup set
  20. channel ORA_DISK_1: starting piece 1 at 09-OCT-15
  21. channel ORA_DISK_1: finished piece 1 at 09-OCT-15
  22. piece handle=+ARCH/orcl/backupset/2015_10_09/ncsnn1_wbg_0.313.892653581 tag=WBG comment=NONE
  23. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
  24. Finished backup at 09-OCT-15

随后,我胡乱瞎写一个tag

点击(此处)折叠或打开

  1. RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF tag '222222222222233333333' DATABASE;
  2. Starting backup at 09-OCT-15
  3. using channel ORA_DISK_1
  4. no parent backup or copy of datafile 2 found
  5. no parent backup or copy of datafile 1 found
  6. no parent backup or copy of datafile 5 found
  7. no parent backup or copy of datafile 3 found
  8. no parent backup or copy of datafile 4 found
  9. channel ORA_DISK_1: starting incremental level 0 datafile backup set
  10. channel ORA_DISK_1: specifying datafile(s) in backup set
  11. input datafile file number=00002 name=+DATA/orcl/datafile/sysaux.257.891365639
  12. input datafile file number=00001 name=+DATA/orcl/datafile/system.256.891365639
  13. input datafile file number=00005 name=+DATA/orcl/datafile/example.266.891365749
  14. input datafile file number=00003 name=+DATA/orcl/datafile/undotbs1.258.891365639
  15. input datafile file number=00004 name=+DATA/orcl/datafile/users.259.891365639
  16. channel ORA_DISK_1: starting piece 1 at 09-OCT-15
  17. channel ORA_DISK_1: finished piece 1 at 09-OCT-15
  18. piece handle=+ARCH/orcl/backupset/2015_10_09/nnndn0_222222222222233333333_0.299.892658295 tag=222222222222233333333 comment=NONE
  19. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
  20. channel ORA_DISK_1: starting incremental level 1 datafile backup set
  21. channel ORA_DISK_1: specifying datafile(s) in backup set
  22. input datafile file number=00006 name=+DATA/orcl/datafile/undotbs2.267.891365925
  23. channel ORA_DISK_1: starting piece 1 at 09-OCT-15
  24. channel ORA_DISK_1: finished piece 1 at 09-OCT-15
  25. piece handle=+ARCH/orcl/backupset/2015_10_09/nnndn1_222222222222233333333_0.298.892658309 tag=222222222222233333333 comment=NONE
  26. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
  27. channel ORA_DISK_1: starting incremental level 1 datafile backup set
  28. channel ORA_DISK_1: specifying datafile(s) in backup set
  29. including current control file in backup set
  30. including current SPFILE in backup set
  31. channel ORA_DISK_1: starting piece 1 at 09-OCT-15
  32. channel ORA_DISK_1: finished piece 1 at 09-OCT-15
  33. piece handle=+ARCH/orcl/backupset/2015_10_09/ncsnn1_222222222222233333333_0.297.892658311 tag=222222222222233333333 comment=NONE
  34. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
  35. Finished backup at 09-OCT-15
日志中看到了:
  1. no parent backup or copy of datafile 2 found
  2. no parent backup or copy of datafile 1 found
  3. no parent backup or copy of datafile 5 found
  4. no parent backup or copy of datafile 3 found
  5. no parent backup or copy of datafile 4 found
但是备份成功了,我现在查看一下,多了什么备份

点击(此处)折叠或打开

  1. BS Key Type LV Size Device Type Elapsed Time Completion Time
  2. ------- ---- -- ---------- ----------- ------------ ---------------
  3. 40 Incr 0 1.45G DISK 00:00:11 09-OCT-15
  4. BP Key: 40 Status: AVAILABLE Compressed: NO Tag: 222222222222233333333
  5. Piece Name: +ARCH/orcl/backupset/2015_10_09/nnndn0_222222222222233333333_0.299.892658295
  6. List of Datafiles in backup set 40
  7. File LV Type Ckp SCN Ckp Time Name
  8. ---- -- ---- ---------- --------- ----
  9. 1 0 Incr 2281289 09-OCT-15 +DATA/orcl/datafile/system.256.891365639
  10. 2 0 Incr 2281289 09-OCT-15 +DATA/orcl/datafile/sysaux.257.891365639
  11. 3 0 Incr 2281289 09-OCT-15 +DATA/orcl/datafile/undotbs1.258.891365639
  12. 4 0 Incr 2281289 09-OCT-15 +DATA/orcl/datafile/users.259.891365639
  13. 5 0 Incr 2281289 09-OCT-15 +DATA/orcl/datafile/example.266.891365749
  14. BS Key Type LV Size Device Type Elapsed Time Completion Time
  15. ------- ---- -- ---------- ----------- ------------ ---------------
  16. 41 Incr 1 37.02M DISK 00:00:00 09-OCT-15
  17. BP Key: 41 Status: AVAILABLE Compressed: NO Tag: 222222222222233333333
  18. Piece Name: +ARCH/orcl/backupset/2015_10_09/nnndn1_222222222222233333333_0.298.892658309
  19. List of Datafiles in backup set 41
  20. File LV Type Ckp SCN Ckp Time Name
  21. ---- -- ---- ---------- --------- ----
  22. 6 1 Incr 2281303 09-OCT-15 +DATA/orcl/datafile/undotbs2.267.891365925
  23. BS Key Type LV Size Device Type Elapsed Time Completion Time
  24. ------- ---- -- ---------- ----------- ------------ ---------------
  25. 42 Incr 1 17.73M DISK 00:00:01 09-OCT-15
  26. BP Key: 42 Status: AVAILABLE Compressed: NO Tag: 222222222222233333333
  27. Piece Name: +ARCH/orcl/backupset/2015_10_09/ncsnn1_222222222222233333333_0.297.892658311
  28. SPFILE Included: Modification time: 07-OCT-15
  29. SPFILE db_unique_name: ORCL
  30. Control File Included: Ckp SCN: 2281304 Ckp time: 09-OCT-15
由此可见,当你选择的那个tag不存在的话,oracle会帮你先做一个0级备份,并且tag的名字也帮你给上,让增量备份有了自己能参照的0级备份

经过验证,孙姐姐的想法是可以实现的哈!之前感觉木有什么卵用的tag,在这个场景下,非常有用。
oracle的文档很全面,oracle很强大啊。
额。。。。。。赓赓。。。。。。



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30202921/viewspace-1813649/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: Oracle与K-DB的PK
请登录后发表评论 登录
全部评论

注册时间:2015-04-11

  • 博文量
    22
  • 访问量
    70513