3

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"
                }
        }
end

What 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?

  • Did you find the solution? I'm stuck with the same problem. :( – ankush981 Apr 21 '18 at 4:55
  • @dotslash I posted an answer for how I solved it. It's probably not the best solution, but it works. – CodeLikeBeaker Apr 23 '18 at 12:58
  • Thank you! I did end up doing something similar myself. I don't know Lua so there was no way I was going to write loops, but it looks like multiple sync blocks does the trick. :o) – ankush981 Apr 23 '18 at 19:02
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.