11

I have two Ubuntu machines, a laptop and a desktop. What I wish to do is, to create a folder in both machines at paths 'path1' and 'path2'. I want to set up sync between the two folders whenever they are connected to the same local area network (Desktop through Ethernet and Laptop through WLAN). So for example, if I create a file path1/x, it will also appear in path2 as path2/x.

Is there a way I can get this done? [It's ok if deletion sync doesn't work and I have to manually delete a file from both directories simultaneously]

8

[Answering my own question as I found a nice way to do this]

Use unison tool developed by Benjamin Pierce at U Penn.

Let us assume you have two directories,

/home/user/Documents/dirA/ and /home/user/Documents/dirB/

To synchronize these two, you may use:

~$unison -ui text /home/user/Documents/dirA/ /home/user/Documents/dirB/

In output, unison will display each and every directory and file that is different in the two directories you have asked to sync. It will recommend to additively synchronize (replicate missing file in both locations) on the initial run, then create and maintain a synchronization tree on your machine, and on subsequent runs it will implement true synchronization (i.e., if you delete a file from .../dirA, it will get deleted from .../dirB as well. You can also compare each and every change and optionally choose to forward or reverse synchronize between the two directories.

Optionally, to launch graphical interface, simply remove the -ui text option from your command, although I find the cli simpler and faster to use.

More on this: Unison tutorial at Unison user documentation.

| improve this answer | |
-2

Check out this tutorial on how to sync folders using rsync.

Cheers

| improve this answer | |
  • 2
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – RolandiXor Jan 1 '17 at 22:39
  • 2
    For the community to be more effective, it is necessary to provide more detail in the answers, a link is not enough, in which case it is not an answer but rather a comment. – Ale Mar 20 '18 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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