mac[linux]使用lsyncd 实时同步两台机器的多个文件
Lsyncd是什么?
Lsyncd是一种轻量级的实时文件备份解决方案,非常容易安装和使用。
可以用来同步两天机器之间的文件。
更多使用方案可参阅: https://github.com/axkibe/lsyncd
安装
brew install lsyncd
brew install rsync
配置文件
~/MyApp/sync.lua
settings {
logfile = "/var/log/lsyncd.log", --日志路径
statusFile = "/var/log/lsyncd.status", --状态文件
pidfile = "/var/run/lsyncd.pid", --pid文件路径
statusInterval = 1, --状态文件写入最短时间
nodaemon = true, --daemon运行
maxProcesses = 1, --最大进程
maxDelays = 1, --最大延迟
insist=true,
}
sourceList = {}
sourceList['/Users/hncg/MyApp/service'] = '/home/cg/MyApp/service'
sourceList['/Users/hncg/MyApp/sites.d'] = '/home/cg/MyApp/sites.d'
for from_source, target_source in pairs(sourceList) do
sync {
default.rsync,
source = from_source,
delete = true,
target = "[email protected]:"..target_source,
exclude = {".idea/*",".git/*","assets/*","node_modules/*","runtime/*","tmp/*","__pycache__/*"},
rsync = {
binary = "/usr/local/bin/rsync",
-- binary = "/usr/bin/rsync",
archive = true,
compress = true,
bwlimit = 2000,
rsh = "ssh -i /Users/hncg/.ssh/id_rsa"
-- rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
-- 如果要指定其它端口,请用上面的rsh
}
}
end运行
sudo lsyncd ~/MyApp/sync.lua
提示
rsync可不安装,binary配置选择注释的那行即可。 brew install lsyncd 安装之后默认,rsync默认会安装到/usr/bin/rsync。 但是可能会报错 'rsync: -pstglozD: unknown option',应该是版本的问题。 所以解决方案是自己再通过 brew install rsync 安装一个rsync。 brew install rsync默认会安装到/usr/local/bin/rsync。
相关推荐
xiaoemo0 2020-06-17
awoyaoc 2020-06-12
wiseMale 2020-05-31
会哭的雨 2020-05-30
ITlover00 2020-05-26
plusz 2020-05-09
深井兮兮 2020-05-01
jiangtie 2020-04-30
净无邪 2020-04-26
Wytheme 2020-02-16
secondid 2020-02-03
秋风瑟瑟 2020-01-06
会哭的雨 2019-12-12
insularisland 2019-12-06
leodengzx 2019-12-03
博小瑾 2014-03-18
ourtimes 2015-05-02
云计算和大数据 2019-11-12