6

I am using unison to sync a bunch of folders together. Not just 2 roots, but I think my question can be made this simple...

Lets say I am syncing directory A and B using unison. If I remove file X from directory A, how does unison know what to do? Should it add X back to A from B or should it delete X from B?

1 Answer 1

9

Unison keeps a record of the contents of each path after each successful synchronization of that path (i.e., it remembers the contents at the last moment when they were the same in the two replicas).

We say that a path is updated (in some replica) if its current contents are different from its contents the last time it was successfully synchronized. Note that whether a path is updated has nothing to do with its last modification time—Unison considers only the contents when determining whether an update has occurred. This means that touching a file without changing its contents will not be recognized as an update. A file can even be changed several times and then changed back to its original contents; as long as Unison is only run at the end of this process, no update will be recognized.

In other words: Unison knows that you have deleted file X, because it's no longer on the disk in A, it knows it should delete it from B.

3
  • What about a 'fresh start' synchronization? If I have files in A, and nothing in B, and start a sync from A - will files be copied to B, or removed from A?
    – drowe
    Commented Apr 28, 2011 at 16:52
  • In this case, it will merge the 2 roots, meaning, the files will be added on both ends, nothing will be deleted.
    – kclement
    Commented Dec 14, 2011 at 16:25
  • 1
    In a 'fresh start' synchronization, it will actually ask before adding the file on the other end. Unison does not know if A or B is "correct" in this case. So it will give you the option to either add it or remove it from both ends.
    – PonyEars
    Commented Jan 30, 2013 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.