一键同步脚本

一键同步脚本
#!/bin/bash
bash_path=$(cd "$(dirname "$0")";pwd)
source $bash_path/base.config

echo "该脚本将会把" $serverA "机器上的" $document "目录同步到" $serverB "机器上";
read -p "是否要继续?(y|n) "
 
rs() {
    /usr/bin/rsync -azP \
    --exclude logs \
    --exclude upload \
    --exclude caches \
    --exclude tmp \
$document/ $serverB:$parent/$document/
 
}
 
if [ $REPLY == 'y' -o $REPLY == 'Y' ]
then
    echo "即将同步……"
    sleep 2
    cd $parent
    rs $serverB
#    rs C
    echo "同步完成。"   
elif [ $REPLY == 'n' -o $REPLY == 'N' ]
then
    exit 1
else
    echo "请输入字母y或者n"
fi
rScript 一键同步脚本
# 源端
serverA=192.168.3.67
# 目标端
serverB=192.168.3.68
# 需要同步的文件夹
document=dockerfile
# 上一级目录
parent=/root
base.config

 

上一篇:Linux 系统一键备份脚本


下一篇:Excel导出 Exceltable.js