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
master.darin.web.id
ip address : 103.43.x.34
slave.darin.web.id
ip address : 103.43.x.36
sync directory : /var/www/html
vim /etc/lsyncd.conf
settings {
logfile = "/var/log/lsyncd.log",
statusFile = "/var/log/lsyncd.stat",
statusInterval = 1,
}
sync {
default.rsyncssh,
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 {
default.rsync,
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
}
}
end
systemctl restart lsyncd systemctl enable lsyncd
Reference : https://github.com/axkibe/lsyncd