Syncronizing your usb and hard disk with Unison

Today I decided to automate the tedious process of syncronising my SD card and hard drive (for example to get files to an e-book reader faster and be able to read from it more often (which is way better than straining your eyes reading from a monitor)). The good thing is that you can later use the same technique to sync USBs, external hard drives, even remote machines via ssh or ftp – you just tweak the paths.

First I thought of Linux’ rsync command, but Unison is suggested as a bit more user-friendly and abstract program that achieves the deed. Here’s how you do it.

1) Install Unison:

sudo apt-get install unison

Optionally, also install the gui:

sudo apt-get install unison-gtk

2) Plug in your usb, SD card, whatever. An icon should appear on Ubuntu’s desktop right when it mounts. Open it and copy the path from nautilus’ bar. Should be someghing like /media/disk.

3) Start unison with the two paths (the one on your usb and the one to your local folder) and the -perms=0 option (might not work otherwise if one of the folders is on a FAT filesystem):

unison -perms=0 /media/disk/desired/folder/on/it /home/user/desired/local/folder

It will ask you some questions which you can answer by hitting return. Or you can add the -batch options and you won’t be prompted for anything.


Note: one of the paths can be remote, haven’t tried it in terminal, but from the gui it’s very straightforward.

Published by


Building apps, analysing data at Punk Rock Dev and sharing weird & cool photographs, drawings, music, films, games... More about me here. You can get new blog posts via RSS or follow @metakermit on Twitter where I also announce new stuff.

Leave a Reply

Your email address will not be published. Required fields are marked *