我在周日使用以下全局脚本进行 0 级(完全)增量备份:
printing stored global script: weekly_backup
{
allocate channel DISK1 device type disk format '&1/&2_Disk1_%U.bkp';
allocate channel DISK2 device type disk format '&1/&2_Disk2_%U.bkp';
allocate channel DISK3 device type disk format '&1/&2_Disk3_%U.bkp';
backup section size 1g incremental level 0 as compressed backupset
tag '&2'
keep until time 'SYSDATE+&3'
restore point '&2'
database plus archivelog;
delete noprompt obsolete;
}
周一到周六,我运行以下 RMAN 命令进行 1 级增量备份:
run {
backup section size 1g incremental level 1 as compressed backupset archivelog all database;
delete noprompt obsolete;
}
我的重要设置:
RMAN> show all;
RMAN configuration parameters for database with db_unique_name RCATN are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
现在,当我连续几天使用参数 15 调用脚本时,我的 0 级备份集具有相应的 Keep 值:
(我在 2019 年 3 月 28 日运行的所有其余命令)
RMAN> list backupset tag=L0_2019_03_17;
List of Backup Sets
===================
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ -------------------
4349986 7.90M DISK 00:00:01 2019-03-17 02:05:12
BP Key: 4349990 Status: AVAILABLE Compressed: YES Tag: L0_2019_03_17
Piece Name: /mnt/shares/backup/RCATN/L0_2019_03_17_Disk2_sgtskh2n_1_1.bkp
Keep: BACKUP_LOGS Until: 2019-04-01 02:05:11
...
但是当我列出所有备份集时,它显示我有几天的 1 级增量备份,这些备份比我最旧的 0 级(完整)备份还要早:
RMAN> list backupset summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
4324675 B 1 A DISK 2019-03-07 2 1 YES TAG20190307T020510
4324676 B 0 A DISK 2019-03-07 1 1 YES TAG20190307T020510
4324677 B 1 A DISK 2019-03-07 1 1 YES TAG20190307T020510
4325630 B A A DISK 2019-03-07 1 1 NO TAG20190307T120513
4326388 B A A DISK 2019-03-08 1 1 NO TAG20190308T000512
4326760 B A A DISK 2019-03-08 1 1 YES TAG20190308T020510
4326761 B 1 A DISK 2019-03-08 1 1 YES TAG20190308T020510
4326762 B 1 A DISK 2019-03-08 2 1 YES TAG20190308T020510
4327695 B A A DISK 2019-03-08 1 1 NO TAG20190308T120513
4332857 B A A DISK 2019-03-09 1 1 NO TAG20190309T000508
4333313 B A A DISK 2019-03-09 1 1 YES TAG20190309T020508
4333314 B 1 A DISK 2019-03-09 1 1 YES TAG20190309T020508
4333315 B 1 A DISK 2019-03-09 2 1 YES TAG20190309T020508
4334294 B A A DISK 2019-03-09 1 1 NO TAG20190309T120512
4335404 B A A DISK 2019-03-11 1 1 NO TAG20190311T000508
4335904 B A A DISK 2019-03-11 1 1 YES TAG20190311T020509
4335905 B 1 A DISK 2019-03-11 1 1 YES TAG20190311T020509
4335906 B 1 A DISK 2019-03-11 2 1 YES TAG20190311T020509
4336825 B A A DISK 2019-03-11 1 1 NO TAG20190311T120508
4337610 B A A DISK 2019-03-12 1 1 NO TAG20190312T000508
4338006 B A A DISK 2019-03-12 1 1 YES TAG20190312T020509
4338007 B 1 A DISK 2019-03-12 1 1 YES TAG20190312T020509
4338008 B 1 A DISK 2019-03-12 2 1 YES TAG20190312T020509
4338956 B A A DISK 2019-03-12 1 1 NO TAG20190312T120508
4339810 B A A DISK 2019-03-13 1 1 NO TAG20190313T000508
4340248 B A A DISK 2019-03-13 1 1 YES TAG20190313T020507
4340249 B 1 A DISK 2019-03-13 1 1 YES TAG20190313T020507
4340250 B 1 A DISK 2019-03-13 2 1 YES TAG20190313T020507
4341190 B A A DISK 2019-03-13 1 1 NO TAG20190313T120508
4342684 B A A DISK 2019-03-14 1 1 NO TAG20190314T000508
4343074 B A A DISK 2019-03-14 1 1 YES TAG20190314T020508
4343075 B 1 A DISK 2019-03-14 1 1 YES TAG20190314T020508
4343076 B 1 A DISK 2019-03-14 2 1 YES TAG20190314T020508
4344192 B A A DISK 2019-03-14 1 1 NO TAG20190314T120508
4345115 B A A DISK 2019-03-15 1 1 NO TAG20190315T000509
4345510 B A A DISK 2019-03-15 1 1 YES TAG20190315T020508
4345511 B 1 A DISK 2019-03-15 1 1 YES TAG20190315T020508
4345512 B 1 A DISK 2019-03-15 2 1 YES TAG20190315T020508
4346447 B A A DISK 2019-03-15 1 1 NO TAG20190315T120508
4347266 B A A DISK 2019-03-16 1 1 NO TAG20190316T000509
4347630 B A A DISK 2019-03-16 1 1 YES TAG20190316T020508
4347631 B 1 A DISK 2019-03-16 1 1 YES TAG20190316T020508
4347632 B 1 A DISK 2019-03-16 2 1 YES TAG20190316T020508
4348621 B A A DISK 2019-03-16 1 1 NO TAG20190316T120509
4349564 B A A DISK 2019-03-17 1 1 NO TAG20190317T000509
4349986 B A A DISK 2019-03-17 1 1 YES L0_2019_03_17
4349987 B A A DISK 2019-03-17 1 1 YES L0_2019_03_17
4350036 B 0 A DISK 2019-03-17 1 1 YES L0_2019_03_17
4350037 B 0 A DISK 2019-03-17 1 1 YES L0_2019_03_17
4350038 B 0 A DISK 2019-03-17 1 1 YES L0_2019_03_17
4350039 B 0 A DISK 2019-03-17 2 1 YES L0_2019_03_17
4350061 B A A DISK 2019-03-17 1 1 YES L0_2019_03_17
4350062 B A A DISK 2019-03-17 1 1 YES L0_2019_03_17
4350079 B F A DISK 2019-03-17 1 1 YES L0_2019_03_17
4350097 B F A DISK 2019-03-17 1 1 YES L0_2019_03_17
4350114 B A A DISK 2019-03-17 1 1 YES L0_2019_03_17
4351780 B A A DISK 2019-03-17 1 1 NO TAG20190317T120509
4352876 B A A DISK 2019-03-18 1 1 NO TAG20190318T000508
4353260 B A A DISK 2019-03-18 1 1 YES TAG20190318T020508
4353261 B 1 A DISK 2019-03-18 1 1 YES TAG20190318T020508
4353262 B 1 A DISK 2019-03-18 2 1 YES TAG20190318T020508
4354185 B A A DISK 2019-03-18 1 1 NO TAG20190318T120508
...
如果我列出 1 级增量备份的详细信息(我在上面的摘要列表中选择了第一个),我看不到任何 KEEP 数据:
RMAN> list backupset 4324675;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4324675 Incr 1 380.61M DISK 00:01:15 2019-03-07
List of Datafiles in backup set 4324675
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- ---------- ----------- ------ ----
3 0 Incr 40466491 2019-03-07 NO /u01/app/oracle/oradata/rmcat/sysaux01.dbf
Backup Set Copy #1 of backup set 4324675
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:01:15 2019-03-07 YES TAG20190307T020510
List of Backup Pieces for backup set 4324675 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
4324680 1 AVAILABLE /u01/app/oracle/recovery_area/RCATN/backupset/2019_03_07/o1_mf_nnnd1_TAG20190307T020510_g80vlp4r_.bkp
4324681 2 AVAILABLE /u01/app/oracle/recovery_area/RCATN/backupset/2019_03_07/o1_mf_nnnd1_TAG20190307T020510_g80vn3cq_.bkp
RMAN>
那么为什么 RMAN 保留比我最旧的 0 级备份更早的 1 级备份呢?
根据 Backup and Recovery Reference,KEEP 选项的解释:
使用说明
KEEP
RMAN在计算备份保留策略时不考虑带有选项的备份片段。如果可用,RMAN 将这些备份用于灾难恢复还原操作,但它们的目的是生成可以在另一个系统上还原的数据库快照,以供测试或历史使用。那么,您在没有该选项的情况下进行的最后一次备份
full
或备份是什么时候?所有和从那时起仍然被计算为执行恢复窗口所需的,因此并没有过时。inc0
KEEP
inc1
archivelogs
转自评论:
只保留一个星期
inc0
,保留两个月是没有意义的。inc1
他们一起工作。您需要做的第一件事是将您的
RETENTION_POLICY
from更改REDUNDANCY
为RECOVERY_WINDOW
. 然后只需DELETE OBSOLETE
在每个备份作业中包含一个,然后让 RMAN 计算出哪些可以删除,哪些不能删除。请记住,这些存档备份将被他们的KEEP UNTIL <date>
而不是RETENTION POLICY
.