1

I'm using LSync to synchronize the web root for two separate CentOS 7 servers running Apache. So far, it seems to be running decently, but every so often, I notice that lsync doesn't process the files properly.

An example of the issue I'm having - If I have a file called hello-world.txt on server01 and server02, and I delete it from server01, when lsync runs, instead of deleting it from server02, it actually re-creates it on server01.

I haven't found anything online about this, and I'm new to using lsync, so I'm not quite sure how to go about fixing this.

Not sure it's needed, but here's the lsync configuration file (/etc/lsyncd.conf):

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

sync {
    default.rsync,
    source="/var/www/",
    target="192.168.1.36:/var/www/",
    rsync={
        rsh = "/usr/bin/ssh -l lsync -i /etc/lsync/.ssh/id_rsa", 
    }
}

Any help would be appreciate! thanks!

Justin
  • 1,959
  • 5
  • 22
  • 40
  • Does the file get recreated when you *start* lsyncd, or when you delete a file while lsyncd is *already running*? – ams Apr 21 '16 at 09:04

1 Answers1

1

lsyncd does not do bidirectional synchronization; its purpose is to make that directory look like this directory, continuously.

You could achieve the same effect by running rsync as a cron job. The only difference is that lsyncd is more responsive when files are changed, and more efficient when files are idle.

With extreme care, you could set up lsyncd on both servers, syncing in both directions, and then you might get what you want, but that relies on updates being not too rapid (when server01 sends an update to server02, server02 will detect that change and attempt to send it right back to server01, which is harmless as long as that file has not changed again). I'd not recommend this setup; use SyncThing, or only make edits to the "master" server.

ams
  • 24,923
  • 4
  • 54
  • 75
  • "With extreme care, you could set up lsyncd on both servers, syncing in both directions" That's exactly what I have setup.. and whats causing the issue. There shouldn't be updates too often. – Justin Apr 20 '16 at 20:10
  • That might have been relevant info in the question! – ams Apr 20 '16 at 22:16
  • You could try using `default.rsyncssh` instead of `default.rsync`. See the docs as there's a few differences in the options you need to set. The point is that it will do `ssh rm ` instead of using `rsync` to delete files. – ams Apr 21 '16 at 09:03
  • The title says **master-master/bi-directional setup**, lol. Sorry, I guess I could have elaborated. – Justin Apr 21 '16 at 17:04