要实现ERP系统的自动tar备份,必须要考虑的问题.
1.利用crontab脚本自动执行
2.应用和数据库关闭干净
3.必须定期检查磁盘空间
4.备份后系统自动启动
1)vi /etc/crontab
---------------------------------------------------------------------------------
00 00 * * * applprod /home/applprod/scripts/stopapp.sh>>/tmp/log/erp.log
00 01 * * * oraprod /home/oraprod/scripts/stopdb.sh>>/tmp/log/erp.log
00 03 * * * oraprod /home/oraprod/scripts/startdb.sh>>/tmp/log/erp.log
30 03 * * * applprod /home/applprod/scripts/startapp.sh>>/tmp/log/erp.log
2.1)stopapp.sh
---------------------------------------------------------------------------------
##--close the Application
sh /ora/ORACLE_SID/saegcomn/admin/scripts/ORACLE_SID/adstpall.sh apps/apps
##
2.2)stopdb.sh
---------------------------------------------------------------------------------
###判断application是否关闭掉
###it is closed cleanlily
while true
do
user1="` ps -ef|grep applprod|grep -v "bash"|grep -v "ps -ef"|grep -v "grep applprod"|grep -v "su" |awk '{ print $1 }'`";
if [ $? ! -eq 0 ] ; then
sleep 2
#echo $?
else
break;
fi
done;
###
##
##--close the Database
###it is closed cleanlily
sh /ora/ORACLE_SID/saegdb/8.1.7/appsutil/scripts/ORACLE_SID/addbctl.sh stop immediate;
lsnrctl stop ORACLE_SID;
while true
do
user2="` ps -ef|grep oraprod|grep -v "bash"|grep -v "ps -ef"|grep -v "grep oraprod"|grep -v "su"; `";
if [ $? ! -eq 0 ] ; then
sleep 2;
#echo $?;
else
break;
fi
done;
###
##
#--backup the APPL,DATA,COMN,ORA,DB
cd /ora/ORACLE_SID;
dt=`date -d " a day ago " +%Y%m%d`
#磁盘空间
if [ -f ORACLE_SID$dt ] ;then
rm ORACLE_SID$dt;
fi
tar cvzf /ora/saebackup/ORACLE_SID$(date +%Y%m%d).tar.gz *;
#--startup DB
sh /ora/ORACLE_SID/saegdb/8.1.7/appsutil/scripts/ORACLE_SID/addbctl.sh start ;
#--startup TNS
lsnrctl start ORACLE_SID;
2.3)startapp.sh
---------------------------------------------------------------------------------
#--startup the Application
sh /ora/ORACLE_SID/saegcomn/admin/scripts/ORACLE_SID/adstrtal.sh apps/apps
阅读(1200) | 评论(0) | 转发(0) |