How to auto sync modified file to another server using Lsyncd on Centos 7

How to auto sync modified file to another server using Lsyncd on Centos 7

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 acheived.

Lsyncd is open source and you can view all feature and contribute on

How to Install Lsyncd on Centos 7

To install Lsyncd on Centos 7, first you need to enable EPEL Repository On CentOS 7 / RHEL 7

If command above does not work or CentOS 6 / RHEL 6 you can manually install with:

Then install Remi repository with command:

Configuration file is on /etc/lsyncd.conf

Example: We want to sync the folder “/var/www/html/” from Master server to Slave server

Enable Key based authentication between Master and Slave Server.

Login to Master server & generate the public and Private keys using ssh-keygen command.

Then the public key from Master to Slave using ssh-copy-id command

First you must login from Master server to Slave server before start lsyncd, or you will get error below on lsyncd

Example configuration of /etc/lsyncd.conf

Enable lsyncd service and start lsyncd service

Check status on /var/log/lsyncd/lsyncd.log with command

Example output

Leave a Reply

Your email address will not be published. Required fields are marked *