lsyncd

From wiki.filipefonseca.pt
Jump to navigation Jump to search


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. See the manual for details.

Lsyncd 2.2.1 requires rsync >= 3.1 on all source and target machines.

License: GPLv2 or any later GPL version.


Service Configuration

install
apt install lsyncd
must create config folder
mkdir -p /etc/lsyncd
create config file (LUA)
vi /etc/lsyncd/lsyncd.conf.lua

Configuration example files

lsyncd.conf.lua example
#logging
settings {
    logfile = "/var/log/lsyncd/lsyncd.log",
    statusFile = "/var/log/lsyncd/lsyncd.status", 
}
#folder setup
sync {
    default.rsyncssh,
    source = "/home/vmail",
    host = "DEST_HOST",
    targetdir = "/home/vmail",
    delay=3,
    rsync     = { 
	compress = true,
	verbose = true,
	update = true,
	perms = true,
	owner = true,
	group = true,	
	rsh = "/usr/bin/ssh -p12345 -o StrictHostKeyChecking=no" }, #NOT default ssh port!
    ssh = {
    	port = 12345 #NOT default ssh port!
    }   
}
#second folder
#...
sync {
    default.rsyncssh,
    source = "/etc/letsencrypt",
    host = "DEST_HOST",
    targetdir = "/etc/letsencrypt",
    delay=3,
    rsync     = { 
	compress = true,
	verbose = true,
	update = true,
	perms = true,
	owner = true,
	group = true,	
	rsh = "/usr/bin/ssh -p12345 -o StrictHostKeyChecking=no" }, #NOT default ssh port!
    ssh = {
    	port = 12345 #NOT default ssh port!
    }   
}

if your using default.rsyncssh, then you must setup ssh keys. in this case, ssh uses 12345 port, not the default 22.