Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2997724
  • 博文数量: 454
  • 博客积分: 4860
  • 博客等级: 上校
  • 技术积分: 6375
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-13 10:08
个人简介

10年工作经验,专研网站运维。

文章分类

全部博文(454)

文章存档

2017年(11)

2016年(13)

2015年(47)

2014年(36)

2013年(147)

2012年(64)

2011年(136)

分类: 系统运维

2013-04-17 15:46:41

[root@hostname ~]$ cat Autobackup.sh
#!/bin/bash
###
###  The script is auto cold backup EBS service.
###  It about need 5 hours.
###  Pay attention to run it by penske account
###  Current appTier and DBTier is running.
###

# Define variable
penske_home=/d01/penske
date=`date +%Y%m%d%H%M`
PSline=12
psline=12
firsttime=1
lasttime=50

# Stop EBS appTier service
cd $penske_home
source /home/penske/.apps
echo "It's stopping application Tier"
$INST_TOP/admin/scripts/adstpall.sh apps/pass*****>>$penske_home/Autobackup"$date".log 2>&1
sleep 120s
#Judge whether FND* process is end
while [ $PSline -ge 2 ]
do
echo "It's stopping"
sleep 20s
PSline=`ps -ef | grep FND* | wc -l | awk '{print $1}'`
if [ $firsttime -lt $lasttime ];then
echo "Wait twenty second"
else
break;
fi
let "firsttime++"

done
#Kill process of unfinished 
echo "FND process can't stop normally. It will be killed immediately"
ps -ef | grep FND* | awk '{print $2}' > /home/penske/FNDpid.txt
for FNDpid in `cat /home/penske/FNDpid.txt`;
do
kill -9 "$FNDpid"
done
echo "It's stopped successful">>$penske_home/Autobackup"$date".log 2>&1
echo -e "Yeah  \nIt's ok">>$penske_home/Autobackup"$date".log 2>&1
sleep 20s
rm -rf /home/oracrp/FNDpid.txt

# Preclone
source /home/penske/.ora11g
cd $ORACLE_HOME/appsutil/scripts/PROD_PLASPASHCN13/
perl adpreclone.pl dbTier>>$penske_home/Autobackup"$date".log 2>&1
sleep 300s
source /home/penske/.apps
cd $INST_TOP/admin/scripts/
perl adpreclone.pl appsTier>>$penske_home/Autobackup"$date".log 2>&1
sleep 300s

# Stop EBS dbTier service
source /home/penske/.ora11g
echo "It's stopping Database Tier"
$ORACLE_HOME/appsutil/scripts/PROD_PLASPASHCN13/addlnctl.sh stop prod>>$penske_home/Autobackup"$date".log 2>&1
sleep 60s
$ORACLE_HOME/appsutil/scripts/PROD_PLASPASHCN13/addbctl.sh stop immediate prod>>$penske_home/Autobackup"$date".log 2>&1
sleep 120s
while [ $psline -ge 2 ]
do
echo "It's running, for a moment"
sleep 5s
psline=`ps -ef | grep ora_ | wc -l | awk 'print $1'`
done
echo “It’s backuping ora11g directory”>>$penske_home/Autobackup"$date".log 2>&1

# Cold backup by tar command
tar zcfp /d01/bak_clone_to137/ora11g"$date".tar.gz ./ora11g>>$penske_home/Autobackup"$date".log 2>&1
echo “It’s backuping R12apps directory”>>$penske_home/Autobackup"$date".log 2>&1
tar zcfp /d01/bak_clone_to137/R12apps"$date".tar.gz ./R12apps>>$penske_home/Autobackup"$date".log 2>&1
echo "It's backuping proddata directory">>$penske_home/Autobackup"$date".log 2>&1
tar zcfp /d01/bak_clone_to137/proddata"$date".tar.gz ./proddata>>$penske_home/Autobackup"$date".log 2>&1
echo “It’s completed all backup processing”>>$penske_home/Autobackup"$date".log 2>&1
sleep 30s

# Start EBS service
echo "It's starting Database Tier">>$penske_home/Autobackup"$date".log 2>&1
/d01/penske/ora11g/db/tech_st/11.1.0/appsutil/scripts/PROD_plaspashcn13/addlnctl.sh start prod>>$penske_home/Autobackup"$date".log 2>&1
sleep 100s
/d01/penske/ora11g/db/tech_st/11.1.0/appsutil/scripts/PROD_plaspashcn13/addbctl.sh start prod>>$penske_home/Autobackup"$date".log 2>&1
sleep 160s
source /home/penske/.apps
echo "It's starting application Tier">>$penske_home/Autobackup"$date".log 2>&1
/d01/penske/R12apps/inst/apps/PROD_plaspashcn13/admin/scripts/adstrtal.sh apps/pass****>>Autobackup"$date".log 2>&1
sleep 300s

# Display result information
echo "The EBS service is startup successful">>$penske_home/Autobackup"$date".log 2>&1
echo "The script log message in /d01/penske/Autobackup"$date".log. Please review it"

 

阅读(3972) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~