CSync2

Commands

csync2 – cluster synchronization tool, 2nd generation

csync2 [-v..] [-C config-name] [-D database-dir] [-N hostname] [-p port]...
-x [-d] [[-r] file..]Run checks for all given files and update remote hosts.
-rRecursive operation over subdirectories
-dDry-run on all remote update operations
-kCreate key file
-rRecursive operation over subdirectories
-BDo not block everything into big SQL transactions. This slows down csync2 but allows multiple csync2 processes to access the database at the same time. Use e.g. when slow lines are used or huge files are transferred.
-XAlso add removals to dirty db when doing a -TI run.
include /etc/drbd.conf;
include /etc/drbd.d/*.res;

Synchronize

csync2 -xv
csync2 -xv -C conffiles

Create key file

csync2 -k /etc/csync2.key

Config file

$ cat /etc/csync2_conffiles.cfg 
nossl * *;
group conffiles
{
        host ares zeus;
        key /etc/csync2.key;
        include /opt/testdir;
        auto none;
        backup-directory /var/csync2/backup;
        backup-generations 3;
}

Misc

Documentation

https://github.com/LINBIT/csync2/blob/master/doc/csync2.adoc

https://daguilopez07.medium.com/bidirectional-file-sync-in-centos-7-csync2-lsyncd-fec4432ec90b

Errors

File stays in dirty state. Try again later…

Make sure the config file is identical on all nodes !!