Bidirectional File Sychronization with Unison: My First Experience

The rsync command is my go-to utility for sync'ing files from one folder to another, but it has issues with bidirectional synchronization (Search "rsync bidirectional sync" for explanations of the problem). Fortunately there are other options.

In the discussions I looked at a program named Unison was consistently suggested for bidirectional syncs. If you're a MacOS user like me, it can be installed with Homebrew. I gave it a try for synchronizing markdown files between two directories on the same computer. It's working perfectly.

Thoughts and observations on Unison:

  • It just worked!
  • There isn't a lot of documentation floating around. If you have a more-than-basic use case you may spend a lot of time experimenting.
  • Use the -batch flag if you're scripting, especially if you're looping on a READ command.
  • The regex is a basic implementation. You may not be able to use the expression you want if it's more than a basic match.
  • I wish there was more control over output. There is the -terse switch. It didn't give me exactly what I wanted, though it was close enough.
  • Some of the switches, like -ignore, are awkward to use in an ad-hoc command line. Not an issue for scripts. There's a profile feature for configuring source/destination pairs with options (I haven't tried it).
  • I should note that unison can sync remote directories over ssh. I didn't need this feature and haven't tried it.

Over all I'm happy with Unison.