返回顶部

欢迎来到菜鸟大明儿哥的博客

我们一起交流学习,不断提升自我

ORACLE备份脚本(3-RMAN0级全备)

创建目录 

mkdir  -p  /bak/level0

mkdir  -p  /bak/arch

chown -R oracle:oinstall  /bak/

 

vi  rmanlevel0.sh

 

#!/bin/bash

export ORACLE_SID=test
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_BASE=//u01/app/oracle
backtime=`date +"20%y%m%d%H%M%S"`
cd $ORACLE_HOME/bin
rman target / log=/bak/log/backupall_$backtime.log <<EOF
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
backup incremental level 0 database format '/bak/level0/level0_%d_%s_%p_%u.bak'
tag='level 0' include current controlfile;
sql 'alter system archive log current';
backup archivelog all format '/bak/arch/log_%d_%s_%p_%u.bak' delete all input;
release channel d3;
release channel d2;
release channel d1;
}
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
EOF


find /bak/level0/ -mtime +7 -name "*.bak" -exec rm -rf {} \;
find /bak/arch/ -mtime +7 -name "*.bak" -exec rm -rf {} \;

posted @ 2020-04-13 13:31  菜鸟大明儿哥  阅读(577)  评论(0编辑  收藏  举报