Two-way directory syncer
Interactively synchronize contents of two directories into a merged, up-to-date version. Both sides can each have independent changes that will be resolved.
Usually, I sync files between two sites using the standard
rsync -a
and/or
scp -p
approach.
However, this is very cumbersome and error prone if changes have been carried out on both sides:
For each directory (or even file) that has been touched on either side, it has to be determined
in advance which side should take precedence (e.g. by a preliminary dry-run and manual inspection).
syncd
will ease the task of recursively merging two directories with each having independent
changes: For each file or directory with different attributes (permissions, timestamps, existence,
… – but no content checksum), a proposed bi-directional resolution strategy is derived. The user
can then choose to accept, skip, or provide a custom action for each found difference
interactively.
Merging directories: usage
The only mandatory arguments are the directories to work on. Their order is only relevant in
presence of other arguments that refer to a specific side (a
or b
suffix):
syncd [--delete-excluded[-a|-b]] [--keep-(a|b)] [--dry-run] [--backup[-a|-b]=dirname] a/ b/
--dry-run
- Will show what changes would have been proposed, but without actually doing anything. Afterwards, you can select to re-run with automatically performing all changes, but I am not confident enough to recommend this.
--keep-(a|b)
- Will selectively prevent changes to either side.
--backup[-a|-b]
- Creates the respective directory name relative to the directory to sync and moves into it instead of deleting or replacing, s.t. file contents won’t be lost.
--delete-excluded[-a|-b]
- Per default, several file-/dir-names will be (silently)
skipped, e.g.
*.o
or.git
. (There is currently no way to provide custom exclusions – please edit the list in the code if needed.) Giving this option will ask for deletion on both or either sides instead.
Warning: This tool was built for (and tested with) only certain scenarios. There are still many things to be done regarding error recovery, atomicity, and correctness/robustness in general. Use only interactively, offline, and with caution!
To build locally, simply type make
. No special dependencies or additional external libraries are
needed. System-wide installation is not required but make install
will (build and) copy the binary
into the system. make uninstall
will remove it again.