備份保留策略
備份保留策略的目的是確保資料庫的可恢復性的同時提高空間利用率,它決定了那些資料檔案需要被備份及短期性檔案如何被刪除。一般是通過命令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的備份保留策略
- python保留7天備份檔案Python
- ORACLE備份策略(轉)Oracle
- ORACLE備份策略二(轉)Oracle
- 資料庫備份策略資料庫
- 【rman備份策略】實驗
- MySQL遠端備份策略舉例MySql
- MySQL中如何選擇合適的備份策略和備份工具MySql
- Python自定義阿里雲RDS備份策略Python阿里
- oracle10g RMAN增量備份策略Oracle
- mysqlbinlog命令詳解 Part 9 MySQL備份策略MySql
- Oracle ADG環境下的RMAN備份策略Oracle
- 【SQLServer備份策略】透過Windows任務計劃程式清理SQLServer歷史備份SQLServerWindows
- [Linux]經典面試題 - 系統管理 - 備份策略Linux面試題
- 如何在Ubuntu保留檔案系統和備份當前開發板映象Ubuntu
- InfluxDB—資料保留策略(Retention Policies)介紹UX
- 時序資料庫InfluxDB之備份和恢復策略資料庫UX
- 時序資料庫 InfluxDB 之備份和恢復策略資料庫UX
- python 備份檔案,從 D盤 到Z盤。並且保留15天的檔案Python
- ELK日誌保留7天-索引生命週期策略索引
- 在Linux中,如何配置和管理系統備份和恢復策略?Linux
- mysql的冷備份與熱備份MySql
- 初探MySQL資料備份及備份原理MySql
- Mysql備份與恢復(1)---物理備份MySql
- NBU指令碼:檢視啟用或未啟用加速的備份策略指令碼
- alias 備份
- 備份dockerDocker
- 備份命令
- oracle資料庫備份之exp增量備份Oracle資料庫
- Mysql備份與恢復(2)---邏輯備份MySql
- ManagerDB 備份檔案管理與異地備份
- 群暉NAS備份建議及備份方式
- 開發必備詞典:Mysql保留關鍵字MySql
- GitLab的自動備份、清理備份與恢復Gitlab
- redis不重啟,切換RDB備份到AOF備份Redis
- 熱備份/冷備份/ 冷啟動/熱啟動
- MySQL的冷備份和熱備份概念理解(轉)MySql
- 【RMAN】同時建立多個備份(建立多重備份)