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

}

posted @ 2019-08-14 16:05  归零19  阅读(569)  评论(0编辑  收藏  举报