Syncing two local directories with lsyncd

June 26, 2026

Start with this:

mkdir /boot.backup

From lsyncd's man page:

Lsyncd(1) watches local directory trees through an event monitor interface (inotify, fsevents). It aggregates and combines events for a few seconds and then spawns one or more processes to synchronize the changes. By default this is rsync(1). Lsyncd is thus a light-weight asynchronous live mirror solution that is comparatively easy to install not requiring new filesystems or block devices and does not hamper local filesystem performance.

Read the docs:

cd /usr/share/doc/lsyncd-*
bunzip2 *.bz2
cat README.md

Setup

Create log directory and files:

mkdir /var/log/lsyncd
touch /var/log/lsyncd/lsyncd.{log,status}

Create the init script at /etc/init.d/lsyncd-boot:

#!/sbin/openrc-run

command="/usr/bin/lsyncd"
pidfile="/var/run/lsyncd-boot.pid"
command_args="-rsync /boot /boot.backup -pidfile $pidfile -log scarce"

depend() {
        need zfs-import zfs-mount
}

Enable and start the service:

chmod 755 /etc/init.d/lsyncd-boot
/etc/init.d/lsyncd-boot start
rc-update add lsyncd-boot default