更新web项目时备份脚本

#!/bin/sh
export BUILD_ID=block-release-v1.0
echo 'beginning.......'
# 项目地址
PROJECT_PATH=/home/tomcat/apache-tomcat-7.0.70/webapps
# 项目名称
PROJECT_NAME=block
# tomcat 地址
TOMCAT_HOME=/home/tomcat/apache-tomcat-7.0.70
# 备份地址
BACK_UP_PATH=/home/tomcat/apache-tomcat-7.0.70/bak
if [ ! -d "${BACK_UP_PATH}" ]; then
        echo 'BACK_UP_PATH is not  real  path '
        echo '-----------------------------'
        # mkdir
        mkdir ${BACK_UP_PATH}
fi
if [ ! -d "${PROJECT_PATH}" ]; then
        echo 'PROJECT_PATH is not  real  project path'
        echo '-----------------------------'
        # exit
        exit 1
fi
# $TOMCAT_HOME
if [ ! -d "${TOMCAT_HOME}" ]; then
        echo 'TOMCAT_HOME is not a really path!'
  echo '-----------------------------'
    # exit
        exit 1
fi
# 新建备份路径
BACK_UP_DATE="$(date +%Y%m%d%H%m%S)"
echo "新建备份路径...."
echo "备份日期:" +${BACK_UP_DATE}
cd ${BACK_UP_PATH}
mkdir ${BACK_UP_DATE}
# stop tomcat
cd ${TOMCAT_HOME}/bin
./shutdown.sh
sleep 8
cd ${TOMCAT_HOME}/webapps
#压缩web.zip
unzip web.zip
sleep 5
#从旧项目拷贝jar包到新项目
cd ${PROJECT_PATH}/web/WEB-INF/lib
cp ${PROJECT_PATH}/${PROJECT_NAME}/WEB-INF/lib/* .
# 备份
cd ${BACK_UP_PATH}/${BACK_UP_DATE}
mv ${PROJECT_PATH}/${PROJECT_NAME} .
# 把新项目web的名字改为block
cd ${PROJECT_PATH}
mv web ${PROJECT_NAME}
# 开启项目
cd ${TOMCAT_HOME}/bin
#run
./startup.sh

你可能感兴趣的:(Linux)