Lsyncd is a daemon that enables you to mirror your directories to any other directory on your network, or even locally. Lsyncd uses a filesystem event interface (inotify or fsevents) to watch for changes to local files and directories. The default synchronization method is rsync

ip address : 103.43.x.34
ip address : 103.43.x.36

sync directory : /var/www/html
  1. Install lsyncd on master
    apt -y install lsyncd
    yum -y install epel-release
    yum -y install lsyncd
  2. Generate public key on master
    ssh-keygen -t rsa
  3. Copy public key from master to slave for login without password
    ssh-copy-id [email protected]
  4. Create directory and file for testing
    mkdir /var/www/html
    cd /var/www/html && touch file{1..100}.txt
    cd /var/www/html && fallocate -l 1G dummyfile #create 1G dummyfile
  5. Configure lsyncd on master (example of some configuration can be found in directory /usr/share/doc/lsyncd-2.2.2/examples/)

        vim /etc/lsyncd.conf

  settings {
        logfile         = "/var/log/lsyncd.log",
        statusFile      = "/var/log/lsyncd.stat",
        statusInterval  = 1,    

  sync {
        source    = "/var/www/html",
        host      = "103.43.x.36",
        targetdir = "/var/www/html",
        delay     = 5,

lsyncd multiple target/host

  settings {
  logfile         = "/var/log/lsyncd.log",
  statusFile      = "/var/log/lsyncd.stat",
  statusInterval  = 1,    

servers = { 'proxypass-s3-jkt', 'proxypass-s3-btn'}
for _, server in ipairs( servers ) do
  sync {
    source = "/etc/letsencrypt/live/xxx",
    target = server .. ":/etc/letsencrypt/live/xxx",
    rsync    = {
        archive  = true,
        compress = true,
        perms    = true,
        owner    = true,
        update   = true,
        whole_file = true

systemctl restart lsyncd
systemctl enable lsyncd

Reference :