I have the following lsyncd script which will sync across my www folder from a single server to multiple destinations:
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" } }
endWhat I'd like to do is have a second set of source folders that I'd like to sync with the servers. So with /var/www, I'd like to add /var/folder.
How would I go about doing this with lsyncd?
31 Answer
I ended up just adding a second set of folders below the first set in the config like this. I'm not sure if this is the best approach, but it works.
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