I was looking for my options to sync files from Server A to Server B so I found Lsyncd
For the installation
sudo apt update
sudo apt install lsyncd
We need to create the configuration
sudo mkdir /etc/lsyncd /var/log/lsyncd
Now, create the following file
sudo nano /etc/lsyncd/lsyncd.conf.lua
And add the following configuration
settings {
logfile = "/var/log/lsyncd/lsyncd.log",
statusFile = "/var/log/lsyncd/lsyncd.status",
}
sync {
default.rsyncssh,
source = "/home/folder/tosync",
host = "[email protected]",
targetdir = "/home/folder/destination",
}
If you want to add a custom SSH port and prevent deletion you can do the following:
sync {
default.rsyncssh,
source = "/home/folder/tosync",
host = "[email protected]",
targetdir = "/home/folder/destination",
rsync = {
rsh = "ssh -p 99999", -- Specify the custom SSH port
},
delete = "false" -- Explicitly disable delete behavior
}