multi targets

This commit is contained in:
Axel Kittenberger 2017-02-13 11:27:59 +01:00
parent d6dd37b5bb
commit 8a03b772ea
3 changed files with 35 additions and 2 deletions

View File

@ -4,4 +4,5 @@ title: Frequently Asked Questions
short: FAQ
---
* [How can I call a script after each rsync operation?](postscript)
* [The startup sync works but after that Lsyncd doesn't do anything](nothing-after-startup)
* [How can I sync from one source to multiple targets?](multiple-targets)
* [The startup sync works but after that Lsyncd doesn't do anything!](nothing-after-startup)

View File

@ -0,0 +1,32 @@
---
layout: default
title: "FAQ: How can I sync from one source to multiple targets?"
---
If you got multiple targets, you simple specify the sync command multiple times.
{% highlight lua %}
sync{ default.rsync, source='/sourcedir', target='targethost1:/targetdir' }
sync{ default.rsync, source='/sourcedir', target='targethost2:/targetdir' }
sync{ default.rsync, source='/sourcedir', target='targethost3:/targetdir' }
{% endhighlight %}
Lsyncd will notice multiple uses of the same source directory or the use of a subdirectory of an already used source directory and creates only watch per subdirectoy watched in any sync.
To remedy the multiplication of the same configuration you can even use a loop to configure multiple targets.
This is the same configuration as before using a loop:
{% highlight lua %}
targets = {
'targethost1:/targetdir',
'targethost2:/targetdir',
'targethost3:/targetdir',
}
for _, target in ipairs( targets )
do
sync{ default.rsync, source='/sourcedir', target=target }
end
{% endhighlight %}
## [ back to FAQ index](../)

View File

@ -1,6 +1,6 @@
---
layout: default
title: "FAQ: The startup sync works but after that Lsyncd doesn't do anything"
title: "FAQ: The startup sync works but after that Lsyncd doesn't do anything!"
---
This almost always caused by the fact you specified a network mounted directory as source.