備份保留策略
備份保留策略的目的是確保資料庫的可恢復性的同時提高空間利用率,它決定了那些資料檔案需要被備份及短期性檔案如何被刪除。一般是通過命令configure進行配置,持久儲存與控制檔案和恢復編錄中,策略分為兩種:備份冗餘讀和恢復視窗的大小。由configure retentionn policy命令設定,與report need backup、report obsolete、delete obsolete命令及快速恢復區配合使用。無論採取那種保留策略,如果rman認為某個備份需要保留,那麼該備份之後產生的歸檔日誌也必須保留。
一:備份冗餘度
##備份冗餘度是指同一檔案(
指包含控制檔案和資料檔案)的備份數量,比如將冗餘度設定為1,表示
控制檔案和所有的資料檔案只需要保留一份全備份及其後期產生的歸檔日誌
##1.將備份策略設定為冗餘度2
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored
##2.先將之前的備份全部刪除,通過以下命令檢視有那些檔案需要備份
###bkps:表示當前擁有的備份數量(包含disk備份和copy兩種型別)
RMAN> report need backup;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
1 0 /oradata/orcl/system01.dbf
2 0 /oradata/orcl/users02.dbf
3 0 /oradata/orcl/sysaux01.dbf
4 0 /oradata/orcl/undotbs01.dbf
5 0 /oradata/orcl/lhh02.dbf
7 0 /oradata/orcl/users01.dbf
##3.執行第一次備份,再次檢視需要的備份資訊
RMAN> backup database;
Starting backup at 19-MAR-22
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/orcl/system01.dbf
input datafile file number=00003 name=/oradata/orcl/sysaux01.dbf
input datafile file number=00007 name=/oradata/orcl/users01.dbf
input datafile file number=00004 name=/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/oradata/orcl/lhh02.dbf
input datafile file number=00002 name=/oradata/orcl/users02.dbf
channel ORA_DISK_1: starting piece 1 at 19-MAR-22
channel ORA_DISK_1: finished piece 1 at 19-MAR-22
piece handle=/home/oracle/fra/ORCL/backupset/2022_03_19/o1_mf_nnndf_TAG20220319T125817_k3brq9jl_.bkp tag=TAG20220319T125817 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 19-MAR-22
Starting Control File and SPFILE Autobackup at 19-MAR-22
piece handle=/home/oracle/fra/ORCL/autobackup/2022_03_19/o1_mf_s_1099738206_k3brqdq1_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 19-MAR-22
##說明:#bkps=1說明已經有一次全備記錄了
RMAN> report need backup;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
1 1 /oradata/orcl/system01.dbf
2 1 /oradata/orcl/users02.dbf
3 1 /oradata/orcl/sysaux01.dbf
4 1 /oradata/orcl/undotbs01.dbf
5 1 /oradata/orcl/lhh02.dbf
7 1 /oradata/orcl/users01.dbf
##4.再次進行全備
RMAN> backup database;
Starting backup at 19-MAR-22
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/orcl/system01.dbf
input datafile file number=00003 name=/oradata/orcl/sysaux01.dbf
input datafile file number=00007 name=/oradata/orcl/users01.dbf
input datafile file number=00004 name=/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/oradata/orcl/lhh02.dbf
input datafile file number=00002 name=/oradata/orcl/users02.dbf
channel ORA_DISK_1: starting piece 1 at 19-MAR-22
channel ORA_DISK_1: finished piece 1 at 19-MAR-22
piece handle=/home/oracle/fra/ORCL/backupset/2022_03_19/o1_mf_nnndf_TAG20220319T130006_k3brtp9c_.bkp tag=TAG20220319T130006 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 19-MAR-22
Starting Control File and SPFILE Autobackup at 19-MAR-22
piece handle=/home/oracle/fra/ORCL/autobackup/2022_03_19/o1_mf_s_1099738206_k3brtscy_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 19-MAR-22
##再次檢視那些檔案需要備份滿足備份策略
##這裡已經沒有任何檔案輸出,
RMAN> report need backup;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
二:備份保留視窗
設定備份視窗保留日期
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS ;
##檢視需要備份的資訊
RMAN> report need backup;
RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 7 days
Report of files that must be backed up to satisfy 7 days recovery window
File Days Name
---- ----- -----------------------------------------------------
1 1878 /oradata/orcl/system01.dbf
3 1878 /oradata/orcl/sysaux01.dbf
4 1878 /oradata/orcl/undotbs01.dbf
5 17 /oradata/orcl/lhh02.dbf
7 1878 /oradata/orcl/users01.dbf
##執行手工備份後再次檢視備份資訊
##這裡發現report need backup命令已經不輸入任何檔案資訊了,那麼也就是意味這時間視窗策略僅僅需要一份備份就能滿足策略條件,只不過是視窗時間內的備份片不會過期
RMAN> backup database;
Starting backup at 19-MAR-22
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/oradata/orcl/system01.dbf
input datafile file number=00003 name=/oradata/orcl/sysaux01.dbf
input datafile file number=00007 name=/oradata/orcl/users01.dbf
input datafile file number=00004 name=/oradata/orcl/undotbs01.dbf
input datafile file number=00005 name=/oradata/orcl/lhh02.dbf
input datafile file number=00002 name=/oradata/orcl/users02.dbf
channel ORA_DISK_1: starting piece 1 at 19-MAR-22
channel ORA_DISK_1: finished piece 1 at 19-MAR-22
piece handle=/home/oracle/fra/ORCL/backupset/2022_03_19/o1_mf_nnndf_TAG20220319T131402_k3bsnt6z_.bkp tag=TAG20220319T131402 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 19-MAR-22
Starting Control File and SPFILE Autobackup at 19-MAR-22
piece handle=/home/oracle/fra/ORCL/autobackup/2022_03_19/o1_mf_s_1099738206_k3bsnx9w_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 19-MAR-22
RMAN> report need backup;
RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 7 days
Report of files that must be backed up to satisfy 7 days recovery window
File Days Name
---- ----- -----------------------------------------------------
三:過期備份片處理
1.備份策略修改成保留兩份
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored
2.執行兩次全備
RMAN> backup database;
RMAN> backup database;
3.檢視是否還需要備份滿足備份策略
##這裡已經滿足備份策略
RMAN> report need backup;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
Report of files with less than 2 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------
##再次進行全備
RMAN> backup database;
RMAN> backup database;
4.檢視備份片資訊
Status: AVAILABLE表示此備份片是可用的
RMAN> list backupset of database;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
104 Full 1.16G DISK 00:00:05 19-MAR-22
BP Key: 116 Status: AVAILABLE Compressed: NO Tag: TAG20220319T135804
Piece Name: /home/oracle/fra/ORCL/backupset/2022_03_19/o1_mf_nnndf_TAG20220319T135804_k3bw7dh7_.bkp
List of Datafiles in backup set 104
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
1 Full 3753713 19-MAR-22 NO /oradata/orcl/system01.dbf
2 Full 3754250 19-MAR-22 NO /oradata/orcl/users02.dbf
3 Full 3753713 19-MAR-22 3753832 NO /oradata/orcl/sysaux01.dbf
4 Full 3753713 19-MAR-22 NO /oradata/orcl/undotbs01.dbf
5 Full 3753713 19-MAR-22 NO /oradata/orcl/lhh02.dbf
7 Full 3754250 19-MAR-22 NO /oradata/orcl/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
106 Full 1.16G DISK 00:00:05 19-MAR-22
BP Key: 118 Status: AVAILABLE Compressed: NO Tag: TAG20220319T135929
Piece Name: /home/oracle/fra/ORCL/backupset/2022_03_19/o1_mf_nnndf_TAG20220319T135929_k3bwb1vb_.bkp
List of Datafiles in backup set 106
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
1 Full 3753713 19-MAR-22 NO /oradata/orcl/system01.dbf
2 Full 3754250 19-MAR-22 NO /oradata/orcl/users02.dbf
3 Full 3753713 19-MAR-22 3753832 NO /oradata/orcl/sysaux01.dbf
4 Full 3753713 19-MAR-22 NO /oradata/orcl/undotbs01.dbf
5 Full 3753713 19-MAR-22 NO /oradata/orcl/lhh02.dbf
7 Full 3754250 19-MAR-22 NO /oradata/orcl/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
108 Full 1.16G DISK 00:00:02 19-MAR-22
BP Key: 120 Status: AVAILABLE Compressed: NO Tag: TAG20220319T140028
Piece Name: /home/oracle/fra/ORCL/backupset/2022_03_19/o1_mf_nnndf_TAG20220319T140028_k3bwcwh4_.bkp
List of Datafiles in backup set 108
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
1 Full 3753713 19-MAR-22 NO /oradata/orcl/system01.dbf
2 Full 3754250 19-MAR-22 NO /oradata/orcl/users02.dbf
3 Full 3753713 19-MAR-22 3753832 NO /oradata/orcl/sysaux01.dbf
4 Full 3753713 19-MAR-22 NO /oradata/orcl/undotbs01.dbf
5 Full 3753713 19-MAR-22 NO /oradata/orcl/lhh02.dbf
7 Full 3754250 19-MAR-22 NO /oradata/orcl/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
110 Full 1.16G DISK 00:00:03 19-MAR-22
BP Key: 122 Status: AVAILABLE Compressed: NO Tag: TAG20220319T140958
Piece Name: /home/oracle/fra/ORCL/backupset/2022_03_19/o1_mf_nnndf_TAG20220319T140958_k3bwxpm9_.bkp
List of Datafiles in backup set 110
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
1 Full 3753713 19-MAR-22 NO /oradata/orcl/system01.dbf
2 Full 3754250 19-MAR-22 NO /oradata/orcl/users02.dbf
3 Full 3753713 19-MAR-22 3753832 NO /oradata/orcl/sysaux01.dbf
4 Full 3753713 19-MAR-22 NO /oradata/orcl/undotbs01.dbf
5 Full 3753713 19-MAR-22 NO /oradata/orcl/lhh02.dbf
7 Full 3754250 19-MAR-22 NO /oradata/orcl/users01.dbf
##檢視過期備份
##一共有四個備份集,策略是保留2份,因此有裡兩個備份集是過期的
RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log 949 17-MAR-22 /oradata/arch/1_529_1086360874.dbf
Archive Log 951 19-MAR-22 /oradata/arch/1_530_1086360874.dbf
Archive Log 952 19-MAR-22 /oradata/arch/1_531_1086360874.dbf
Backup Set 357 19-MAR-22
Backup Piece 357 19-MAR-22 /home/oracle/backup/fulli30opnkm_1_1
Backup Set 358 19-MAR-22
Backup Piece 358 19-MAR-22 /home/oracle/backup/fulli40opnkt_1_1
5.刪除過期備份集
RMAN> delete noprompt obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/oradata/arch/1_530_1086360874.dbf thread=1 sequence=530
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/oradata/arch/1_531_1086360874.dbf thread=1 sequence=531
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Archive Log 949 17-MAR-22 /oradata/arch/1_529_1086360874.dbf
Backup Set 357 19-MAR-22
Backup Piece 357 19-MAR-22 /home/oracle/backup/fulli30opnkm_1_1
Backup Set 358 19-MAR-22
Backup Piece 358 19-MAR-22 /home/oracle/backup/fulli40opnkt_1_1
deleted archived log
archived log file name=/oradata/arch/1_529_1086360874.dbf RECID=949 STAMP=1099562507
deleted backup piece
backup piece handle=/home/oracle/backup/fulli30opnkm_1_1 RECID=357 STAMP=1099751062
deleted backup piece
backup piece handle=/home/oracle/backup/fulli40opnkt_1_1 RECID=358 STAMP=1099751070
Deleted 3 objects
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31462978/viewspace-2874063/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【RMAN】RMAN的備份保留策略
- rman備份集的保留策略
- RMAN說,我能備份(9)--RMAN增量備份與備份保留策略
- RMAN 常用操作命令二(備份保留策略)
- Backup And Recovery User's Guide-RMAN備份概念-備份保留期策略GUIIDE
- Backup And Recovery User's Guide-RMAN備份概念-備份保留期策略-備份冗餘GUIIDE
- Backup And Recovery User's Guide-RMAN備份概念-備份保留期策略-過期備份的批量刪除GUIIDE
- Backup And Recovery User's Guide-RMAN備份概念-備份保留期策略-恢復視窗GUIIDE
- RMAN 備份保留策略的常見問題 (文件 ID 2017258.1)
- rman 備份策略
- ORACLE備份策略Oracle
- 保留最新N份備份目錄指令碼指令碼
- Oracle備份及備份策略及基於Linux下 Oracle 備份策略(RMAN)OracleLinux
- OM裡保留記錄備份SQLSQL
- Backup And Recovery User's Guide-備份RMAN備份-備份保留期對備份的備份的影響GUIIDE
- ORACLE備份策略(轉)Oracle
- linux 備份策略Linux
- 資料備份策略
- SQL Server 備份策略SQLServer
- ORACLE備份策略(1)Oracle
- ORACLE備份策略(2)Oracle
- ORACLE備份策略(3)Oracle
- ORACLE備份策略(4)Oracle
- Backup policy(備份策略)
- RMAN 備份策略 scripts
- Mac備份策略:更好的Mac備份指南Mac
- python保留7天備份檔案Python
- ORACLE備份策略二(轉)Oracle
- 資料庫備份策略資料庫
- 【rman備份策略】實驗
- 轉 Linux 備份策略Linux
- RAC下的備份策略
- 網站資料定時備份指令碼分享 (保留最近的30份備份資料)網站指令碼
- RMAN說,我能備份(18)--制訂備份策略
- RAC模式下的備份策略以及RMAN備份指令碼模式指令碼
- SQL Server 備份遷移策略SQLServer
- [轉載] Oracle備份策略(精華)Oracle
- 資料庫備份基本策略資料庫