首页 > 其他 > 详细

rmanbak.sh

时间:2021-02-08 10:47:50      阅读:19      评论:0      收藏:0      [点我收藏+]


#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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!