RMAN恢復指令碼案例

kisslfcr發表於2015-07-15
$ crontab -l
0 12,19 * * * $ORACLE_HOME/scripts/arcbkup.sh
59 03 * * *  $ORACLE_HOME/scripts/dbbkup.sh
30 9 * * *  $ORACLE_HOME/scripts/delete.sh
5 20 * * * $ORACLE_HOME/nmon.sh

$ more $ORACLE_HOME/scripts/arcbkup.sh
#/usr/bin/sh
#. XXX.env
. XXX.env
rman target /  cmdfile=XXX/bkup_proarc.rman log=XXX.log
exit 0
$ more /u3/ERP/db/tech_st/11.2.0/scripts/dbbkup.sh
#/usr/bin/sh
#. XXX.env
. XXX.env
rman target / cmdfile=XXX/bkup_orapro.rman log=XXX.log
exit 0
$ more /u3/ERP/db/tech_st/11.2.0/scripts/delete.sh
#/usr/bin/sh
#. XXX.env
. XXX.env
rman target /  cmdfile=XXX/delete.rman log=XXX.log
exit 0

$ more bkup_proarc.rman
run {
allocate channel aaa device type sbt;
sql 'alter system archive log current';
backup
     filesperset 40
     format 'al_%s_%p_%t'
     archivelog all delete input;
release channel aaa;
}
$ more bkup_orapro.rman
run {
allocate channel c1 device type sbt;
allocate channel c2 device type sbt;
backup
     filesperset 40
     format '%d_%t_%s_%p'
     tag tiv_full
     database;
sql 'alter system archive log current';
backup
     filesperset 60
     tag arclog
     archivelog all delete input;
backup current controlfile;
release channel c1;
release channel c2;
}
$ more delete.rman
run {
delete noprompt obsolete;
}


另外一種備份方式:
[oracle@mds db]$ more /script/fullback.sh
#!/bin/sh
export ORACLE_HOME=XXX
export ORACLE_SID=XXX
$ORACLE_HOME/bin/rman log=XXX/fullback.log <<EOF
connect target /
connect catalog rman/rman@RMAN
run{
allocate channel 'd1' type disk;
allocate channel 'd2' type disk;
allocate channel 'd3' type disk;
backup incremental level=0 database format='XXX/%U.bak' tag='full_bak';
sql 'alter system archive log current';
backup format 'XXX/log/%U.bak' archivelog from time 'sysdate-7';
DELETE noprompt ARCHIVELOG ALL COMPLETED BEFORE 'sysdate-7';
release channel d1;
release channel d2;
release channel d3;
}
exit;
EOF

[oracle@mds db]$ more XXX/deleteback.sh
#!/bin/sh
export ORACLE_HOME=XXX
export ORACLE_SID=XXX
$ORACLE_HOME/bin/rman log=XXX/deleteback.log <<EOF
connect target /
connect catalog rman/rman@RMAN
run{
crosscheck backup;
delete noprompt obsolete;
}
exit;
EOF



windows平臺備份指令碼(需測試):
RUN {
 allocate channel c1 type disk;
 backup database format 'c:/rman_backup/db_%U' plus archivelog format 'c:/rman_backup/arch_%U';
 release channel c1;
 }

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-1733604/,如需轉載,請註明出處,否則將追究法律責任。

相關文章