Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does unison decide which way to sync a file

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?

like image 871
Jono Avatar asked Dec 21 '10 22:12

Jono


People also ask

How does unison sync work?

Unison works between any pair of machines connected to the internet, communicating over either a direct socket link or tunneling over an encrypted ssh connection.

How does file synchronization work?

File Synchronization (a.k.a. File Sync) is the process of ensuring that two or more locations contain the same, up-to-date, files. If you add, change, or delete a file from one location, the synchronization process will add, change, or delete the corresponding file at the other location.

What is two way file synchronization?

This synchronization process copies files in both directions to coordinate changes as needed. It is expected that the file will change in both locations. These two positions are considered equivalent. Example: If the file is newer in location A, it will be copied to location B.

What is the best way to sync files between computers?

To keep files in sync between two or more computers, many users use cloud storage, such as, Dropbox, Google Drive or OneDrive, which makes it easy and you can access the files on each device. However, the cloud hosting service still has its disadvantages.


1 Answers

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.

like image 87
RoelAdriaans Avatar answered Dec 17 '22 20:12

RoelAdriaans