From Gentoo Wiki
Jump to:navigation Jump to:search

csync2 is a tool for asynchronous file synchronization in clusters.


USE flags

Cannot load package information. Is the atom sys-cluster/csync2 correct?


root #emerge --ask --oneshot sys-cluster/csync2


Create ssl certificates for transfers

root #emerge --config sys-cluster/csync2

Create key for authentication with peers

root #csync2 -k /etc/csync2/csync2.key_mygroup

Setup synchronization

FILE /etc/csync2/csync2.cfg
group mygroup
	host hostname1 host2_ip (hostname3); # (hostname3) can only download changes. - #
	key /etc/csync2/csync2.key_mygroup;  # Identical file for all in group. - #

	include /mnt/shared;                 # Same list for all. - #
	exclude /mnt/shared/local*;

Things to note

  • All nodes (of a group) share a common key, for example /etc/csync2/csync2.key_mygroup. This means it has to be copied to each node.
  • The shared folder paths need to be identical for all nodes (of a group). The configuration file need not be identical.
  • Although the host parameter requires the actual hostname (or ip) to be used, it seems to work according to the /etc/hosts file.
    • The following command shows what csync2 sees as hostname:
    • root #csync2 -Tvv |& head


To enable the service to run at system boot:

root #rc-update add csync2 default

To start the daemon now:

root #rc-service csync2 start


Sample parameters

        -x [-d] [[-r] file..]   Run checks for all given files and update
                                remote hosts.
        -d      Dry-run on all remote update operations
        -P peer1,peer1,...
                Only update these peers (still mark all as dirty).
                Only show files for these peers in -o (compare) mode.
        -f [-r] file..          Force files to win next conflict resolution.
        -r      Recursive operation over subdirectories.
        -M      List all dirty files from status db.


  • Update all with this one:
    • root #csync2 -x
  • Dry-run an update towards hostname3:
    • root #csync2 -P hostname3 -xd
    • Increased verbosity:
      • root #csync2 -P hostname3 -xdvvvvv
  • Force local files onto others:
    • root #csync2 -fr /mnt/shared/force_these
      root #csync2 -x


See also

External resources