码迷,mamicode.com
首页 > 其他好文 > 详细

rmanbak.sh

时间:2021-02-09 11:53:37      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:bak   alter   rm -rf   log   ble   locate   ann   disk   set   


#creation:2021-02-02
#Define variable
date=`date +%Y%m%d`
basedir=/data2/backup

#Create
cd $basedir
mkdir rmanbak0_$date

#delete expire document
#find $basedir -name "rmanbak0_*" -mtime +7 |xargs rm -rf

#Create pfile from spfile
sqlplus / as sysdba <<EOF
create pfile=‘$basedir/rmanbak0_$date/pfile$date.ora‘ from spfile;
EOF

#RMAN BACKUP DATABASE
rman target / log=$basedir/rmanbak0_$date/rman_$date.log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup database filesperset 4 format ‘$basedir/rmanbak0_$date/rman_full_%d_%T_%s_%p‘;
sql ‘alter system archive log current‘;
sql ‘alter system archive log current‘;
backup archivelog all format ‘$basedir/rmanbak0_$date/rman_arch_%d_%T_%s_%p‘ delete input;
#backup archivelog all format ‘$basedir/rmanbak0_$date/rman_arch_%d_%T_%s_%p‘;
#delete archivelog until time ‘sysdate-7‘;
backup current controlfile format ‘$basedir/rmanbak0_$date/rman_ctl_%d_%T_%s_%p‘;
release channel c1;
release channel c2;
release channel c3;
release channel c4;

}
EOF

#cd $basedir
#tar -zcvf rmanbak$date.tar.gz rmanbak$date
#rm -rf rmanbak$date
#see tar -xzvf rmanbak$date.tar.gz

rmanbak.sh

标签:bak   alter   rm -rf   log   ble   locate   ann   disk   set   

原文地址:https://www.cnblogs.com/oracle-ziyuhou/p/14387594.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!