Lsyncd watches a local directory trees event monitor interface (inotify or fsevents).
It aggregates and combines events for a few seconds and then spawns one (or more) process(es) to synchronize the changes.
By default this is rsync.
Lsyncd is thus a light-weight live mirror solution that is comparatively easy to install not requiring new filesystems or block devices and does not hamper local filesystem performance.
Rsync+ssh is an advanced action configuration that uses a SSH to act file and directory moves directly on the target instead of re-transmitting the move destination over the wire.
Fine-grained customization can be achieved through the config file.
Custom action configs can even be written from scratch in cascading layers ranging from shell scripts to code written in the Lua language.
This way simple, powerful and flexible configurations can be achieved.
Lsyncd is open source and you can view all feature and contribute on https://github.com/axkibe/lsyncd
How to install and auto sync using Lsyncd
To install Lsyncd on Centos 7, first you need to enable EPEL Repository On CentOS 7 / RHEL 7
For CentOS/RHEL 7 Only
[root@serverdiary ~]# yum install epel-release
If command above does not work or CentOS 6 / RHEL 6 you can manually install with:
For CentOS/RHEL 7
[root@serverdiary ~]# yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
For CentOS/RHEL 6
[root@serverdiary ~]# yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
Then install Remi repository with command:
[root@serverdiary ~]# yum install lua lua-devel pkgconfig gcc asciidoc
[root@serverdiary ~]# yum install lsyncd
Configuration file is on /etc/lsyncd.conf
Example: We want to sync the folder “/var/www/html/serverdiary.com” from Master server to Slave server
Master Server's IP = 192.168.10.5
Slave Server’s IP = 192.168.10.6
Directory to be sync = /var/www/html/serverdiary.com
Enable Key based authentication between Master and Slave Server.
Login to Master server & generate the public and Private keys using ssh-keygen command.