lsyncd同步排除目录和文件的两种方法
lsyncd同步排除目录和文件的两种方法
先看代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
settings {
nodaemon = false,
logfile = "/var/log/lsyncd.log",
statusFile = "/tmp/log/lsyncd.status",
-- # inotifyMode指定inotify监控的事件,默认是CloseWrite,还可以是Modify。
inotifyMode = "CloseWrite",
maxProcesses = 10
}
-- 可以有多个sync,各自的source,各自的target,各自的模式,互不影响。
sync {
default.rsyncssh,
source = "/var/www/test1",
host = "192.168.0.25",
targetdir = "/var/www/test1",
-- excludeFrom = "/etc/lsyncd_exclude.lst",
exclude = {
".db",
"config/**",
"static/**",
},
-- maxDelays = 5,
delay = 0,
-- init = false,
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
verbose = true,
_extra = {"--bwlimit=2000"},
},
}
重点看下面的代码
1
2
3
4
5
6
7
8
9
-- excludeFrom = "/etc/lsyncd_exclude.lst",
-- 直接把需要排除的文件或目录写入到/etc/lsyncd_exclude.lst
exclude = {
".db",
"config/**",
"static/**",
},
--直接写入lsyncd同步配置文件中,排除所有.db的文件和config,static目录
启动lsyncd -log Exec /etc/lsycd_demo.conf
- - 是注释,线上代码要想实现相关功能记得取消
同步之前要配置密匙无密码登录
💘 相关文章
- lsyncd实时动态同步更新文件的方法
- 使用wget下载指定目录下的所有文件的方法
- linux系统下目录待斜杠和不带斜杠的区别
- openlitespeed/litespeed禁止访问文件夹和文件的方法
- 使用rclone同步文件到backblaze的教程以及rclone常用命令大全
- 国产基于HTTP协议的分布式文件系统
- 这应该是最详细的lsyncd 实时同步数据的教程啦
- lsyncd error: unexplained error (code 255) at io.c(235) [sender=3.1.2]的解决方法
- cifs 挂载nas共享目录记录
- 更改用户home目录 for centos