First perform the above 1 step and then perform the 2 steps, the shell script:
#!/bin/bash
# 此脚本功能为根据构建时选择的参数,同步 /data/www/vhosts/pixcutapi.wondershare.com 下的文件同步到远程中转机器
# 2020.12.02 初始化脚本
#非apache用户运行脚本,则退出
if [ `whoami` != "apache" ];then
echo "only apache can run me"
exit 1
fi
echo "xxx"
## 1.定义变量
dir_name=bak.$(date +%Y-%m-%d-%H-%M-%S)
project_dir=/data/www/vhosts/pixcutapi.wondershare.com
## 2.备份代码函数
function func_project_backup(){
cp -a $project_dir/ /data/data_backup/pixcutapi.wondershare.com_$dir_name
}
func_project_backup
## 3.判断代码发布目录变量是否为空
if [ ! $project_dir ];then
echo "$project_dir IS NULL ,shell exit!!!!"
exit 1
fi
## 2.判断同步状态
functio