---
title: "Oracle rman catalog备份"
author: "microjava"
date: "2009-11-20T09:42:42Z"
tags: []
slug: "oracle-rman-catalog"
draft: false
lastmod: "2009-11-20T09:43:42Z"
id: 520936
url: "https://microjava.iteye.com/blog/520936"
---

config_rman.sh:

```shell

echo 'please input ORACLE_SID:'
read oraclesid
export ORACLE_SID=$oraclesid
sqlplus sys/oracle as sysdba @create_rman.sql

```


create_rman.sql:

```sql

create tablespace rman datafile &file size 50M autoextend on;
create user rman identified by rman default tablespace rman;
grant resource,connect,recovery_catalog_owner to rman;
exit;

```


register_rman.sh:

```shell

echo 'please input ORACLE_SID:'
read oraclesid
export ORACLE_SID=$oraclesid
rman target / catalog rman/rman cmdfile=register_rman.sql

```


register_rman.sql:

```sql

create catalog;
register database;
resync catalog;
exit;

```


realrman.sh:

```shell

#!/bin/bash

rq=`date '+%y%m%d'`;
#echo $rq;

export ORACLE_HOME=/oracle/app/product/9.2;
export ORACLE_SID=ermp;
export PATH=$ORACLE_HOME/bin;$PATH;

rman catalog rman/rman target / msglog=/home/oracle/mybackup/ermp$rq.log<<EOF

set echo on;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/home/oracle/mybackup/$ORACLE_SID-%U.db';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/home/oracle/mybackup/$ORACLE_SID-%F.ctl';
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
backup database format '/home/oracle/mybackup/$ORACLE_SID-%U.db'
plus archivelog format '/home/oracle/mybackup/$ORACLE_SID-%U.arc' delete all input;
list backup summary;
list backup by file;
crosscheck archivelog all;
crosscheck backupset;
delete noprompt obsolete;
exit;
EOF

```