Closed GoogleCodeExporter closed 9 years ago
Multiple targets as a special case are no longer needed. Lsyncd 2 now handles
multiple Syncs. Sources of syncs may be identical, or one even a subdir of
another.
lsyncd -rsync /path/to/src host1::module -rsync /path/to/src host2::module
Don't worry about additional inotify ressources. It will only create one
inotify watch per directory regardless in how many syncs the directory appears.
It was splited so the targets do not interfer which each other. If host1 goes
down, host2 will be synced regardless. Or a slow target does not slow down
other targets.
Original comment by axk...@gmail.com
on 14 Dec 2010 at 7:10
thank you for that! Now a semi-related question. What is best practice in your
opinion when wanting to sync both directions? In other words does lsyncd watch
both source and target if the target is local? Or do I need to create a second
watch in the opposite direction i.e. lsyncd -rsync [source] [target] -rsync
[target] [source] and have them both running at the same time? This is in
regards to failover. Thanks
Original comment by pkbook...@gmail.com
on 14 Dec 2010 at 7:46
If you do vice versa you need two syncs. But change the rsync options then! You
need it to put the partial files in another place and better also only update
when newer. This cannot be done in command line but requires a config file.
Currently 2.0.0 rsyncOps can only be one String, so you cannot specify those,
the best thing to do is to copy the "default_rsync" config out from lsyncd.lua
paste it in your file and change the rsync options to something better fitting
the two-way-sync case.
Current SVN and 2.0.1 will allow you to add several options as rsyncOps.
Original comment by axk...@gmail.com
on 14 Dec 2010 at 7:52
Original comment by axk...@gmail.com
on 17 Dec 2010 at 2:03
Should the lua for syncing to multiple hosts look like:
sync{
default.rsync,
source="/var/www/wiki/",
target="server1:/var/www/wiki/"
}
sync{
default.rsync,
source="/var/www/wiki/",
target="server2:/var/www/wiki/"
}
OR can two targets be specified in one sync? (NOTE: Specifying two targets in
one sync does not result in any complaints from lsyncd)
sync{
default.rsync,
source="/var/www/wiki/",
target="server1:/var/www/wiki/",
target="server2:/var/www/wiki/"
}
Regards,
Randy
Original comment by randy.re...@gmail.com
on 18 May 2011 at 8:52
The former, Lsyncd doesnt see the second as conflict due to Lua syntax this
actually being an array, the second definition overrides the first.
You can also do fancy stuff like following, since the config file is actually
just a Lua script being interpreted:
targetlist = {
"server1:/var/www/wiki/",
"server2:/var/www/wiki/"
}
for _, server in ipairs(targetlist) do
sync{ default.rsync,
source="/var/www/wiki/",
target=server
}
end
Kind regards, Axel
Original comment by axk...@gmail.com
on 18 May 2011 at 9:46
Axel,
i upgraded lsyncd from 2.0.7 to 2.1.5 and trick
for _, server in ipairs(targetlist) do
sync{ default.rsync,
source="/var/www/wiki/",
target=server
}
end
doesn't work any more:
Error: error preparing /home/user/lsyncd.lua: Parameter "target" unknown. (if
this is not a typo add it to checkgauge)
How can one sync multiple targets in lsyncd 2.1?
Thanks!
Original comment by tedo.vrb...@gmail.com
on 25 Sep 2013 at 8:27
Works for me, can you send me your complete config file?
Original comment by axk...@gmail.com
on 25 Sep 2013 at 8:33
OK, problem was in using default.rsyncssh instead of default.rsync.
Original comment by tedo.vrb...@gmail.com
on 25 Sep 2013 at 10:30
This thread was very helpful for my exact situation, but I'm trying to add one
more bit of complexity. I'm attempting to launch a bash script that returns a
list of valid hosts to sync to and put that into an array. I'm a lua newbie and
would appreciate any help. Here's the config:
hostlist=`/home/lsync/hostlist.sh`
hostarray = {}
for host in hostlist:gmatch("%w+") do table.insert(hostarray, host) end
for _, server in ipairs(hostarray) do
sync {
default.rsyncssh,
source = "/test/",
host = server,
targetdir = "/test/",
}
end
Original comment by jeremy.b...@gmail.com
on 8 Oct 2013 at 7:43
can i use the below one ?
if no then how can i use this if I want to sync it through rsync module ?
sync {
default.rsync,
source="server::module/",
target="/var/www/",
}
Original comment by svvap...@gmail.com
on 26 Feb 2014 at 1:47
Original issue reported on code.google.com by
pkbook...@gmail.com
on 14 Dec 2010 at 6:45