RMAN中自动删除解决方案

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

RMAN中自动删除解决方案

有备份就有删除(对于非磁带式备份),对于过期的和冗余的备份要删除,而且要做到自动删除

在9i中方便地提供了命令delete obsolete

8i没有,但8i提供了一个demo删除地脚本rman1.sh,稍微改动一下即可

8.0.5也没有,也没有demo脚本,把8i的考过来,改造之。前端时间以前地一个项目要求rman备份,数据库式8.0.5地,参考了MetaLink script后(上面还是有点问题),研究和改了一下rman1.sh,(呵呵,对于unix shell脚本和sed以及正则表达式还不是很熟悉,搞了半天)

1)msgno参数不支持在8.0.5中,(但实际上是在8.0.5中是默认设置)

2)删除采用shell脚本中取出欲删除文件名,再用sed改造更新一下导成脚本

3)路径前添加了空格分隔符来取,路径需要自己设置

#!/bin/sh

#

# $Header: rman1.sh 04-oct-99.17:07:55 dbeusee Exp $

#

# Copyright (c) 1998, 1999, Oracle Corporation. All rights reserved.

#

# rman1.sh

#

# NAME

# rman1.sh - delete obsolete backups and copies

#

# DESCRIPTION

# This shell script automates deletion of obsolete datafilecopies and

# backup pieces. It uses sed and grep to process the output of the RMAN # "report obsolete" command and constructs an RMAN command file

# containing the necessary "change...delete" commands.

#

# NOTES

# Some customization is necessary.

#

# MODIFIED (MM/DD/YY)

# dbeusee 10/01/99 - demo_rman1_2: removed "rom recovery catalog" from

# comments, since nocatalog can be used (so RC N/A). # mjaeger 07/26/99 - bug 808870: OCCS: convert tabs, no long lines

# dbeusee 07/14/99 - fix_rman1sh_usage: fix usage message for cat/nocat # dbeusee 07/07/99 - fix_demo: add msgno and target/catalog args

# gpongrac 08/11/98 - Creation

#

usage() {

case "$1" in

"") ;;

*) echo "Unknown argument: $1" ;;

esac

echo "

Usage: `basename $0` [option] ...

Option Description

--------------------------- -------------------------------------------------- target CNCTSTR Connect to the target db using CNCTSTR.

catalog CNCTSTR Connect to catalog db using CNCTSTR.

nocatalog Don't use a recovery catalog.

parms 'PARMS' Use PARMS string for SBT_TAPE maintenance channel. You can use single or double quotes depending on your needs. In the rman script, single-quotes

will be used.

The catalog or nocatalog option must be specified. All others are optional (target is defaulted to internal/manager which you may need to override if using a orapwd file for your target db).

NOTE: This is only a sample script. If your needs exceed the capabilities of this script, please feel free to copy it and modify your copy as needed.

"

exit 1

}

# Initialize default connect string variables:

target='target internal/oracle'

catalog='rcvcat rman/rman' # force user to supply catalog option

parms=''

# process target and catalog arguments

while [ $# -gt 0 ]; do

case "$1" in

target) target="$1 $2"; shift ;;

catalog|rcvcat) catalog="$1 $2"; shift ;;

nocatalog) catalog=$1 ;;

parms) parms="$1 '$2'"; shift ;;

*) usage "$1" ;;

esac

shift

done

case "$catalog" in

"") usage ;;

esac

# Initialize filenames:

obsolete_disk=/export/home/oracle/dbbk/bk/script/tmp/ob_disk.log # list of obsolete disk backups

#obsolete_tape=./tmp/ob_tape.log # list of obsolete tape backups

cmdfile=/export/home/oracle/dbbk/bk/script/tmp/delete.cmd # the generated RMAN commmand script

delete_log=/export/home/oracle/dbbk/bk/script/tmp/deleted.log # execution log from generated script

# Get a list of obsolete disk files:

echo 'start rman $target $catalog msglog $obsolete_disk'

rman $target $catalog msglog $obsolete_disk << EOF > /dev/null

相关文档
最新文档