使用rsync, 向另外一台服务器同步目录和文件的脚本
#!/bin/bash
#亚特兰蒂斯-同步目录
#定时任务
ini_file="/usr/local/sunlight/conf/rsync-file.ini"
target_ip="10.108.144.2"
pk_file="/usr/local/sunlight/sshkeys/init.pk"
if [ ! -f $ini_file ];then
echo "[ Error ] `date "+%Y/%m/%d %H:%M:%S"` $ini_file does not exist!"
exit 1
fi
if [ ! -e $pk_file ];then
echo "[ Error ] `date "+%Y/%m/%d %H:%M:%S"` $pk_file does not exist!"
exit 1
fi
while read line
do
if [[ ! -d $line && ! -f $line ]];then
echo "[ Error ] `date "+%Y/%m/%d %H:%M:%S"` direcoty or file: $line does not exist!"
exit 1
fi
if [ ${line:0:1} != "/" ];then
echo " [ Error ] $line must start with /"
exit 1
fi
if [[ -d $line && ${line:0-1:1} != "/" ]];then
line="$line/"
fi
if [ -d $line ];then
ssh -p2222 -i /usr/local/sunlight/sshkeys/init.pk -o strictHostKeyChecking=no $target_ip "test -d $line || mkdir -p $line"
fi
if [ -f $params ];then
param_dir=${line%/*}
ssh -p2222 -i /usr/local/sunlight/sshkeys/init.pk -o strictHostKeyChecking=no $target_ip "test -d $param_dir || mkdir -p $param_dir"
fi
echo "rsync $line......"
rsync -avztog --progress -e "ssh -p2222 -i /usr/local/sunlight/sshkeys/init.pk -o strictHostKeyChecking=no" ${line} ${target_ip}:${line}
done < $ini_file
最新文章
- 【.net深呼吸】动态类型(娱乐篇)
- coding.net
- Android Studio简单设置
- android studio Keymap快捷键
- 【转载】IIS7.5(经典模式)访问静态资源(.css和.js文件)提示:未能执行 URL
- 刷了OpenWrt Attitude Adjustment 12.09,很满意
- 在相同的主机上创建一个duplicate数据库
- 05-树8 File Transfer
- Android 抓包,监控流量工具之 mitmproxy
- paip.c++ qt 共享库dll的建立
- 4.PHP 教程_PHP 变量
- docker镜像与容器概念
- transform复习之图片的旋转木马效果
- Plugin/Preset files are not allowed to export objects,webpack报错/babel报错的解决方法
- mysql常用function
- 第二章&#160;向量(a)接口与实现
- ASP.NET 上传大文件(原创)
- Thinkphp5 使用odbc连接到sqlserver
- centos6 yum安装最新版mysql5.7
- MySQL 逻辑备份工具
热门文章
- 【转】Vue中mintui的field实现blur和focus事件
- 【转】Code First 属性详解
- kali-rolling安装openvas 9并创建扫描任务教程
- kiss prefix paleo,per,pen,pan,para out 1
- Javaconfig形式配置Dubbo多注册中心
- JS 浮点型计算的精度问题 推荐的js 库 推荐的类库 Numeral.js 和 accounting.js
- day05 数据类型
- java中构造方法和方法全面解析
- IO多路复用,select、poll、epoll 编程主要步骤
- (C/C++学习笔记) 六. 表达式