Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger unison sync files and directories when there's any change on OSX?

I have a need to sync two directories on OSX. I find this post recommending using unison.

I tried unison, it seems it can sync two directories very well. But it doesn't do synchronization automatically( always keep two directories synced when there's any change ).

So I guess to accomplish my purpose, unison should be used with a trigger which will watch changes and notify unison to do its work.

But how to do that? Any recommendation and tutorial?

like image 626
Aaron Shen Avatar asked Jan 08 '23 01:01

Aaron Shen


2 Answers

Unison has this capability built in. Just add the line repeat = watch to your Unison profile.

like image 56
Mike Pierce Avatar answered Jan 16 '23 17:01

Mike Pierce


Install Unison:

brew install unison

Install unox:

git clone [email protected]:hnsl/unox.git
cd unox
ln -s $PWD/unox.py /usr/local/bin/unison-fsmonitor

Do the initial sync:

unison -auto -batch dirA dirB

Run the continuous bidirectional sync:

unison -auto -batch -repeat watch -times dirA dirB
like image 20
rentzsch Avatar answered Jan 16 '23 19:01

rentzsch