我有以下 lsyncd 脚本,它将把我的 www 文件夹从单个服务器同步到多个目的地:
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
statusInterval = 10
}
www_target_list = {
"server_one:/var/www",
"server_two:/var/www",
"server_thr:/var/www"
}
for _, server in ipairs(www_target_list) do
sync {
default.rsync,
source = "/var/www/",
target = server,
rsync = {
compress = true,
acls = true,
verbose = true,
owner = true,
group = true,
perms = true,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
}
}
end
我想要的是第二组源文件夹,以便与服务器同步。因此/var/www
,我想添加/var/folder
。
我该如何使用 lsyncd 来做到这一点?
答案1
我最终只是在配置中的第一组文件夹下添加了第二组文件夹,如下所示。我不确定这是否是最好的方法,但它确实有效。
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
statusInterval = 10
}
apache_list = {
"[ip address]:/etc/apache2/sites-available",
"[ip address]:/etc/apache2/sites-available",
"[ip address]:/etc/apache2/sites-available",
}
for _, server in ipairs(apache_list) do
sync {
default.rsync,
source = "/etc/apache2/sites-enabled",
target = server,
rsync = {
compress = true,
acls = true,
verbose = true,
owner = false,
group = false,
perms = false,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
}
}
end
www_list = {
"[ip address]:/var/www",
"[ip address]:/var/www",
"[ip address]:/var/www",
}
for _, server in ipairs(www_list) do
sync {
default.rsync,
source = "/var/www/",
target = server,
rsync = {
compress = true,
acls = true,
verbose = true,
owner = false,
group = false,
perms = false,
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no",
_extra = {"--chmod=0755"}
}
}
end