Wednesday, February 22, 2012

Setup your own Dropbox with Unison

Using Unison in Linux

This does seem to work pretty well. I haven't set it up as a service anywhere, so I have to run it from the command prompt. But, once it gets going, it is quick.

Install Unison on two computers (server and client); uses ssh, so that needs to be installed, too. The version of Unison on both computers must be the same.

http://www.seas.upenn.edu/~bcpierce/unison//download/releases/

Intall OCaml (http://caml.inria.fr/)
sudo yum install ctags-etags ocaml
cd to the unison source directory, then:
make UISTYLE=text
./unison -version
mv unison ~
cd ~
mv unison .unison/
 
Now that the code has been run, the .unison/default.prf has been created; edit (on the client):
# load the common preferences
include common
addprefsto = common
label = default profile
#root = source
#root = /home/username/Desktop/Unison

#root = source2
#root = source2
#root = ssh://login@host.com/Desktop/Unison
#root = ssh://login@host.com/Desktop/Unison

#path = path to sync
#ignore = path to NOT sync

Also on the client, in your home directory, create the .unison/common file:
# Unison preferences fileauto=truebatch=truesshargs = -Ccopythreshold = 1000killserver = truecopyquoterem = trueconfirmbigdel = falsemaxthreads = 5perms=0times=truesilent = true#group=true#owner=trueprefer=newer#crontab -e#*/30 * * * * /usr/bin/unison <profile> &> /dev/null
Use the default.prf file as a template to create a file for your needs (ie "backup.prf"):
# Unison preferences
include common
label = my backup
root = /home/username-on-client
root = ssh://username@domain//media/path/to/destination
path = Name-Of-Directory
This is the commandline I use on the client:
unison backup -auto -ui text
If it isn't working, create a logfile:
unison backup -auto -ui text -logfile unison.log
Once you're happy with it, create a cron job (crontab -e):

*/30 * * * * /path/to/unison backup &>/dev/null
(Don't forget to restart the crond daemon: service crond restart)

You can also use incrond / inotify to call the script on filesystem changes (as opposed to time-based cronjobs.)

[Windows version available here: http://alan.petitepomme.net/unison/index.html]

FYI, to transfer within the same system:
unision -batch <source> <dest>

Advanced Unison Settings

No comments :

Post a Comment