將月末的rman備份設定為永久保留

cnhtm發表於2009-07-09

一、需求:將月末的rman備份設定為永久保留
二、解決思路:
1、可以使用change backup ... keep forever nologs語句將備份集設定為永久保留
2、為了區分需要永久保留的備份集,在月末備份的時候,使用tag標記備份集,即在每個backup語句後加上tag '200907'格式的語句
3、在備份集中不能包含archive log,否則不能使用keep ... nologs選項

三、測試

]> export ORACLE_SID=orcl
]> rman target / catalog

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Jun 15 12:56:45 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: ORCL (DBID=1210313093)
connected to recovery catalog database

RMAN> run{
2> ALLOCATE CHANNEL ch00 TYPE disk;
3> BACKUP INCREMENTAL LEVEL=0 SKIP INACCESSIBLE FILESPERSET 5 FORMAT '/rman/bk_%s_%p_%t' DATABASE tag '200907';
sql 'alter system archive log current';
4> 5> BACKUP FORMAT '/rman/cntrl_%s_%p_%t' CURRENT CONTROLFILE tag '200907';
6> backup FORMAT '/rman/spfile_%s_%p_%t' spfile tag '200907';
7> change backup tag '200907' keep forever nologs;
8> RELEASE CHANNEL ch00;
9> }

starting full resync of recovery catalog
full resync complete
allocated channel: ch00
channel ch00: sid=140 devtype=DISK

Starting backup at 15-JUN-09
channel ch00: starting incremental level 0 datafile backupset
channel ch00: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/oradata/orcl/system01.dbf
input datafile fno=00004 name=/oracle/oradata/orcl/users01.dbf
input datafile fno=00003 name=/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/oracle/oradata/orcl/example01.dbf
input datafile fno=00002 name=/oracle/oradata/orcl/undotbs01.dbf
channel ch00: starting piece 1 at 15-JUN-09
channel ch00: finished piece 1 at 15-JUN-09
piece handle=/rman/bk_5_1_689605193 tag=200907 comment=NONE
channel ch00: backup set complete, elapsed time: 00:05:31
channel ch00: starting incremental level 0 datafile backupset
channel ch00: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ch00: starting piece 1 at 15-JUN-09
channel ch00: finished piece 1 at 15-JUN-09
piece handle=/rman/bk_6_1_689605525 tag=200907 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:07
Finished backup at 15-JUN-09
starting full resync of recovery catalog
full resync complete

sql statement: alter system archive log current

Starting backup at 15-JUN-09
channel ch00: starting full datafile backupset
channel ch00: specifying datafile(s) in backupset
including current control file in backupset
channel ch00: starting piece 1 at 15-JUN-09
channel ch00: finished piece 1 at 15-JUN-09
piece handle=/rman/cntrl_7_1_689605584 tag=200907 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:05
Finished backup at 15-JUN-09

Starting backup at 15-JUN-09
channel ch00: starting full datafile backupset
channel ch00: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ch00: starting piece 1 at 15-JUN-09
channel ch00: finished piece 1 at 15-JUN-09
piece handle=/rman/spfile_8_1_689605599 tag=200907 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:02
Finished backup at 15-JUN-09

keep attributes for the backup are changed
backup will never be obsolete
archived logs required to recover from this backup will not be kept
backup set key=78 recid=4 stamp=689605513
keep attributes for the backup are changed
backup will never be obsolete
archived logs required to recover from this backup will not be kept
backup set key=79 recid=5 stamp=689605530
keep attributes for the backup are changed
backup will never be obsolete
archived logs required to recover from this backup will not be kept
backup set key=110 recid=6 stamp=689605587
keep attributes for the backup are changed
backup will never be obsolete
archived logs required to recover from this backup will not be kept
backup set key=120 recid=7 stamp=689605600

released channel: ch00

RMAN>

四、驗證

RMAN> list backup summary tag '200907';


List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
78 B 0 A DISK 15-JUN-09 1 1 NO 200907
79 B 0 A DISK 15-JUN-09 1 1 NO 200907
110 B F A DISK 15-JUN-09 1 1 NO 200907
120 B F A DISK 15-JUN-09 1 1 NO 200907

RMAN>

tag=200907的備份集共有4個

RMAN> list backup tag '200907';


List of Backup Sets
===================

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
78 Incr 0 1010.14M DISK 00:05:20 15-JUN-09
BP Key: 82 Status: AVAILABLE Compressed: NO Tag: 200907
Piece Name: /rman/bk_5_1_689605193
Keep: NOLOGS Until: FOREVER
List of Datafiles in backup set 78
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 0 Incr 698455 15-JUN-09 /oracle/oradata/orcl/system01.dbf
2 0 Incr 698455 15-JUN-09 /oracle/oradata/orcl/undotbs01.dbf
3 0 Incr 698455 15-JUN-09 /oracle/oradata/orcl/sysaux01.dbf
4 0 Incr 698455 15-JUN-09 /oracle/oradata/orcl/users01.dbf
5 0 Incr 698455 15-JUN-09 /oracle/oradata/orcl/example01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
79 Incr 0 6.80M DISK 00:00:05 15-JUN-09
BP Key: 83 Status: AVAILABLE Compressed: NO Tag: 200907
Piece Name: /rman/bk_6_1_689605525
Keep: NOLOGS Until: FOREVER
Control File Included: Ckp SCN: 698742 Ckp time: 15-JUN-09
SPFILE Included: Modification time: 15-JUN-09

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
110 Full 6.77M DISK 00:00:03 15-JUN-09
BP Key: 113 Status: AVAILABLE Compressed: NO Tag: 200907
Piece Name: /rman/cntrl_7_1_689605584
Keep: NOLOGS Until: FOREVER
Control File Included: Ckp SCN: 698792 Ckp time: 15-JUN-09

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
120 Full 80.00K DISK 00:00:01 15-JUN-09
BP Key: 122 Status: AVAILABLE Compressed: NO Tag: 200907
Piece Name: /rman/spfile_8_1_689605599
Keep: NOLOGS Until: FOREVER
SPFILE Included: Modification time: 15-JUN-09

RMAN>

這是個備份集都設定為永久保留,並且不保留以後的歸檔日誌,即:Keep: NOLOGS Until: FOREVER

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22049049/viewspace-1023973/,如需轉載,請註明出處,否則將追究法律責任。

相關文章