LinuxWeb ServersWebsitesWordPress

How to install lsyncd and sync data between servers

lsyncd is a handy little program that syncs data from one Linux server to another. Using the RSYNC protocol lsyncd monitors for changes to a specific location. When changes are noticed lsyncd syncs those changes to the target Linux server. If you have been following our guide on how to create a high availability network, lsyncd is being used instead of network-attached storage (NAS). We’re going to install lsyncd and configure lsyncd to keep our files in sync over our Linux cluster.

Whilst lsyncd is no replacement for services like CEPH which distribute content over a cluster or NAS storage, it is a suitable trade-off for users who cannot afford to run multiple dedicated servers and who need to sync data over Linux servers. This article is part of a series of articles on creating a High Availability Blog Network.

Other Solutions

If dedicated servers and CEPH are not an option for you. All is not lost. It is possible to create a Highly Available blog network on VPS servers with NAS storage. See how to set up MariaDB Database Replication on a MariaDB Galera Cluster.


  1. How to Create a High Availability Network
  2. How To Install Lsyncd Sync and sync data (This Article)
  3. Set up HAProxy Server to load balance

SSH Keys

Your servers need to be able to ssh into each other without a password. You need to generate an SSH Key and add the key to the slave server. Decide which server to use as a master. This will be the server that syncs changes to the slave server. On the master, Create SSH Keys and add them to the slave.

Install lsyncd Linux

We’re using Ubuntu 20.04 for the purpose of our guide. This command is run on the server that you want to send changes from. Your master if you’re following our guide on H/A this would be one of our VPS servers. Install lsyncd;

apt install lsyncd

Now we want to create the required files for lsyncd to function.

mkdir /var/log/lsyncd
mkdir /etc/lsyncd 
touch /var/log/lsyncd/lsyncd.log
touch /var/log/lsyncd/lsyncdstatus

Configure lsyncd

After installing lsyncd we are now going to configure it to sync data from our master to our slave. So, when any information is added to our master, this will be synced to the slave. Our master and slave will both have WordPress on them. They will connect to our Remote MySQL Database. Open up or create the /etc/lsyncd/lsyncd.conf.lua file

nano /etc/lsyncd/lsyncd.conf.lua

Inside the file specify the files we just created for logs and also specify the location of the files you want to sync. We are syncing the whole /var/www/ folder.

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

serverList = {

sourceList =

for _, server in ipairs( serverList ) do
  for _, source in ipairs( sourceList ) do
          delete = 'running',
          delay = 1,

So you need to edit the serverlist =, host = and sourcelist = sections. Now restart the service. As soon as you do this lsyncd will start syncing the data. Test this by adding a file to your master and that should be synced to the slave.

service lsyncd restart
service lsyncd status

So if you are following the guide on how to get High Availability using NVMe VPS Servers. You now have two backend servers, one is syncing to the other. You can install lsyncd to sync back to the master if required. In the next guide, we will set up HAProxy to load balance and active High Availability.

Related Articles

Leave a Reply

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

Back to top button