oracle:通过shell来运行rman命令

    每次都手工输入一批rman命令来进行备份等操作是很繁琐的事,有什么简便的方法吗?可以的,你可以把这批rman命令写在

 

shell命令里面,需要的时候,运行一下sh即可。下面是一个简单的实例:

 

RMAN> quit


Recovery Manager complete.
[oracle@app ~]$ vi rdemo.sh

[oracle@app ~]$ cat rdemo.sh
#!/bin/bash

rman target / <<!
show all;
exit;
!


[oracle@app ~]$ sh rdemo.sh

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Nov 20 22:04:02 2013

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

connected to target database: ORCL (DBID=1350372074)

RMAN>
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/10.2.0/db_2/dbs/snapcf_orcl.f'; # default

RMAN>

Recovery Manager complete.

 

备注:该shell里面用到了 here  document,如果有对here document不熟悉的,

可以查看http://zh.wikipedia.org/wiki/Here%E6%96%87%E6%A1%A3

 

 

你可能感兴趣的:(oracle)