How do I synchronize in both directions?

I want to use rsync to synchronize two directories in both directions.

I refer to synchronization in classical sense (not how it is meant in rsync manuals):
I want to update the directories in both directions, depending on which of them is newer.

Can this be done by rsync (preferable in a Linux-way)?
If not, what other solutions exist?


Just run it twice, with "newer" mode (-u or --update flag) plus -t (to copy file modified time), -r (for recursive folders), and -v (for verbose output to see what it is doing):

rsync -rtuv /path/to/dir_a/* /path/to/dir_b
rsync -rtuv /path/to/dir_b/* /path/to/dir_a

This won't handle deletes, but I'm not sure there is a good solution to that problem with only periodic sync'ing.


Do you know Unison File Synchronizer?

Unison is a file-synchronization tool for Unix and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other. ...

Note also that it is resilient to failure:

Unison is resilient to failure. It is careful to leave the replicas and its own private structures in a sensible state at all times, even in case of abnormal termination or communication failures.