Oracle rman catalog备份

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


create_rman.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:
echo 'please input ORACLE_SID:'
read oraclesid
export ORACLE_SID=$oraclesid
rman target / catalog rman/rman cmdfile=register_rman.sql


register_rman.sql:
create catalog;
register database;
resync catalog;
exit;


realrman.sh:
#!/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

你可能感兴趣的:(oracle,sql,F#,bash)