增量級別 1 RMAN 未被刪除
我在周日使用以下全域腳本進行 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
轉自評論:
因此,如果我想將每週的 0 級備份保留 2 個月,而僅將增量 1 級備份保留一周,那麼最簡單的方法是什麼?
只保留一個星期
inc0
,保留兩個月是沒有意義的。inc1
他們一起工作。您需要做的第一件事是將您的
RETENTION_POLICY
from更改REDUNDANCY
為RECOVERY_WINDOW
. 然後只需DELETE OBSOLETE
在每個備份作業中包含一個,然後讓 RMAN 計算出哪些可以刪除,哪些不能刪除。請記住,這些存檔備份將被他們的KEEP UNTIL <date>
而不是RETENTION POLICY
.