shell脚本,同步两个服务器文件
#!/bin/sh
PID_FILE=syncapp.pid
#filestore dir
SRC=/movies/app
#nginx root dir
TARGET1=root@125.210.111.111:/movies
TARGET1=root@125.210.111.112:/movies
function sync_files
{
#sync cmd
rsync -rvz -e 'ssh -p 5188' $SRC $TARGET1 &>/dev/null
}
配置说明:
SRC为应用在本地服务器上的存储目录,必须与4.2数据初始化配置中appLocalRootDir的值保持一致;
如果需要同步二台nginx服务器,则脚本修改为:
#!/bin/sh
PID_FILE=syncapp.pid
#app store dir
SRC=/movies/app
#nginx root dir
TARGET1=root@125.210.111.111:/movies
TARGET2=root@125.210.111.112:/movies
function sync_files
{
#sync cmd
rsync -rvz -e 'ssh -p 5188' $SRC $TARGET1 &>/dev/null
rsync -rvz -e 'ssh -p 5188' $SRC $TARGET2&>/dev/null
}