lsyncd/manual/invoking/index.md

77 lines
3.8 KiB
Markdown
Raw Normal View History

2016-06-05 17:30:10 +00:00
---
layout: default
title: Invoking
---
As most Unix tools, Lsyncd will print a synopsis of its command line options when called with --help.
2016-06-08 07:01:58 +00:00
{% highlight shell %}
2016-06-05 17:30:10 +00:00
lsyncd --help
lsyncd -help
2016-06-08 07:01:58 +00:00
{% endhighlight %}
2016-06-05 17:30:10 +00:00
The two hyphens are redundant for Lsyncd. It has no short one letter options and one hyphen will always result into the same as specifying two.
2016-06-08 07:01:58 +00:00
Also like most Unix tools, ```--version``` or ```-version``` will let Lsyncd print its version number.
2016-06-05 17:30:10 +00:00
2016-06-08 07:01:58 +00:00
{% highlight shell %}
2016-06-05 17:30:10 +00:00
lsyncd -version
2016-06-08 07:01:58 +00:00
{% endhighlight %}
2016-06-05 17:30:10 +00:00
Lsyncd 2.1 is designed to be predominantly configured through a config file (see below). The config file can thus be the only command line option.
2016-06-08 07:01:58 +00:00
{% highlight shell %}
2016-06-05 17:30:10 +00:00
lsyncd CONFIGFILE
2016-06-08 07:01:58 +00:00
{% endhighlight %}
2016-06-05 17:30:10 +00:00
Although for standard use or quick testing it can be cursorily configured by command line options. The following will keep a local source and destination directory in sync using rsync:
2016-06-08 07:01:58 +00:00
{% highlight shell %}
2016-06-05 17:30:10 +00:00
lsyncd -rsync /home/USER/src /home/USER/dst
2016-06-08 07:01:58 +00:00
{% endhighlight %}
2016-06-05 17:30:10 +00:00
The target can here be anything that Rsync recognizes.
2016-06-08 07:01:58 +00:00
{% highlight shell %}
2016-06-05 17:30:10 +00:00
lsyncd -rsync /home/USER/src remotehost:dst
2016-06-08 07:01:58 +00:00
{% endhighlight %}
2016-06-05 17:30:10 +00:00
Two (or more) targets are configured by calling -rsync twice (or several times).
2016-06-08 07:01:58 +00:00
{% highlight shell %}
2016-06-05 17:30:10 +00:00
lsyncd -rsync /home/USER/src remotehost1:dst -rsync /home/USER/src remotehost2:dst
2016-06-08 07:01:58 +00:00
{% endhighlight %}
2016-06-05 17:30:10 +00:00
A disadvantage with Rsync synchronization is that normally directory and file moves result in a deletion of the move origin and a retransfer of the move destination of the wire. However, Lsyncd 2 can use ssh commands to move the directories and files locally on the target. To use this use ```-rsyncssh``` followed by the local source directory, the remote host and the target directory there. The REMOTEHOST can include a user like ```me@remotehost.com```.
2016-06-08 07:01:58 +00:00
{% highlight shell %}
2016-06-05 17:30:10 +00:00
lsyncd -rsyncssh /home/USER/src REMOTEHOST TARGETDIR
2016-06-08 07:01:58 +00:00
{% endhighlight %}
2016-06-05 17:30:10 +00:00
When testing Lsyncd configurations ```-nodaemon``` is a pretty handy flag. With this option, Lsyncd will not detach and will not become a daemon. All log messages are additionally to the configured logging facilities printed on the console (_stdout_ and _stderr_).
2016-06-08 07:01:58 +00:00
{% highlight shell %}
2016-06-05 17:30:10 +00:00
lsyncd -nodaemon CONFIGFILE
2016-06-08 07:01:58 +00:00
{% endhighlight %}
2016-06-05 17:30:10 +00:00
2016-11-23 09:19:21 +00:00
There is a difference in behaviour when running with -nodaemon. Lsyncd will not change its working directory to ```/```, as it does when becoming a daemon. Thus relative targets like ```./target``` will work with ```-nodaemon``` but must be specified to absolute paths to work in daemon mode. The source directories will also be turned into absolute paths by Lsyncd. The reason targets are not resolved to absolute paths while sources are is because Lsyncd itself does not care about the format of the target specifier which can also be remote hosts, rsyncd modules, etc. It is opaquely handed to rsync. It cares about the observed directories though.
2016-06-05 17:30:10 +00:00
All log messages are sorted in categories. By default Lsyncd is scarce with log messages. You can turn Lsyncd into a motormouth by specifying ```-log all```.
2016-06-08 07:01:58 +00:00
{% highlight shell %}
2016-06-05 17:30:10 +00:00
lsyncd -log all CONFIGFILE
2016-06-08 07:01:58 +00:00
{% endhighlight %}
2016-06-05 17:30:10 +00:00
This might easily become too much. A particularly useful category is "Exec" which will log the command lines of all processes Lsyncd spawns.
2016-06-08 07:01:58 +00:00
{% highlight shell %}
2016-06-05 17:30:10 +00:00
lsyncd -log Exec CONFIGFILE
2016-06-08 07:01:58 +00:00
{% endhighlight %}
2016-11-23 09:19:21 +00:00
When the initial startup sync fails by default Lsyncd will terminate with an error message. It has been designed this way, so configuration failures are visibly reported to a possibly beginning user. However, in production a remote target might be done, but you want Lsyncd to start nevertheless and keep trying to sync to the remote target until it is up.
{% highlight shell %}
lsyncd -insist -rsync /home/USER/src remotehost:dst
{% endhighlight %}
In production mode it is recommended to have insist on. It can also be specified in the settings{} command in a config file.