Sunday, April 5, 2009

[Linux] Synchronizing directories in both directions using unison

[Referred from http://textmode.at/2008/4/21/data-synchronization-with-rsync-and-unison]

Unison allows you to create profiles for different tasks, in this example I want to synchronize my opera configuration. A profiles goes into a file ending in .prf in the ˜/.unison directory, for example ˜/unison/opera.prf:

times=true
prefer
=newer
root
=/home/solars/.opera
root
=ssh://slave//home/solars/.opera
ignore
=Path images*
ignore
=Path *cache*
ignore
=Path mail*

  • prefer = newer means newer files should always be preferred
  • root = lines indicate the directories to synchronize (note the SSH path)
  • ignore = Path .. ignores the given path

Now you can run it simply with unison opera.

_________________________________________________

My experiment:

I use unison to synchronize data from server to my desktop. So, the program unison must be installed on that server. We can download source file of unison at http://www.seas.upenn.edu/~bcpierce/unison/. Fortunately, the required package, ocaml, is installed before in the server, and the unison is compiled completely. After that, we copy unison to "~/bin" and re-export the PATH enviroment (in server). Note that, all of these works can be done with a normal user permission.

No comments: