将月末的rman备份设置为永久保留

一、需求:将月末的rman备份设置为永久保留
二、解决思路:
1、可以使用change backup ... keep forever nologs语句将备份集设置为永久保留
2、为了区分需要永久保留的备份集,在月末备份的时候,使用tag标记备份集,即在每个backup语句后加上tag '200907'格式的语句
3、在备份集中不能包含archive log,否则不能使用keep ... nologs选项

三、测试

oracle@oracle[/rman]> export ORACLE_SID=orcl
oracle@oracle[/rman]> rman target / catalog rman/rman@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/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/22049049/viewspace-1023973/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值