Martin Paul Eve bio photo

Martin Paul Eve

Professor of Literature, Technology and Publishing at Birkbeck, University of London

Email Books Twitter Github Stackoverflow MLA CORE Institutional Repo ORCID ID  ORCID iD Wikipedia Pictures for Re-Use

Everybody yaks on about backup all the time, but few people actually have a viable setup. They say: "yes, I copy stuff to a USB pen". So, if you do that once a week, how much work would you lose if, just before you undertook the backup, your laptop was stolen? This is exactly what happened to me two months ago except that I had a rigorous backup procedure. I left the British Library and was, one hour later, without my laptop. I bought a new laptop the next day and 6 hours after purchase had the entire thing back up and running and had lost no work. Nothing. This was because I use a system called Unison to synchronize and backup my work.

Unison screenshot

Terminology and Background
There's a few pieces of jargon that need clarification before continuing onto the howto portion of this post. It's also worth noting that I am using Ubuntu Linux as my operating system, but I have used Unison successfully on Windows before. There are also Mac OSX binaries.

Synchronization is the process of making changes on multiple machines and reconciling them.
Backup is the process of archiving a copy of your work to prevent against accidental deletion.
Unison is a cross-platform, open source, free file synchronization utility.
SSH is a secure means to access a remote system over the internet.
Dropbox is a free cloud storage solution.

HOWTO use Unison to backup to Dropbox
This is the easier of two methods, the second of which (SSH) I may well return to in a later post, and allows you to synchronize your work to a Dropbox account which, for many people with under 2GB of work, will be entirely free. Note well, you should never use Dropbox as your primary/only storage location. It can do odd things to your files and also makes you overly reliant on the cloud.

  1. Sign-up for a Dropbox account and install the client. Make a note of the location of your Dropbox directory.
  2. Download a copy of Unison and install this somewhere on your environment path. Windows users should see the Microsoft Help article on PATH for information on this.
  3. Write a unison preferences file and put this somewhere Unison can find it (on *Nix systems this will be under ~/.unison/dropbox.prf, on Windows it will be: C:\Documents and Settings\UserName\.unison\dropbox.prf). Here's what mine looked like:
# Unison preferences file

root = /home/martin/
root = /home/martin/Dropbox/

path = Documents/Work/Uni

After this, I had to create the directory structure inside my Dropbox folder: "Documents/Work/Uni" (on Windows, probably: "c:\My Documents\Work\Uni") -- subdirectories will be automatically created, but unless you specify the root in the config file as the entire directory you want to sync, you need to create the top level directories by hand.

Now, drop to a command prompt (on Windows: Start -> Run -> cmd) and type: unison dropbox

Unison will alert you that this is the first time it has been asked to synchronize and will begin indexing your files. If, when this is done, it looks like the synchronization is doing what you want, I'd recommend aborting (CTRL+C) and starting again as: unison dropbox -batch

The batch mode will automatically sync your changes without asking you to confirm each file.

Dropbox Synchronizing

Tada! You've now synchronized your work to Dropbox and, if you look in your Dropbox client, you will see that it is uploading.

Now, you can make a shortcut on your desktop to this configuration which means that all it takes at the end of a day, or lunchtime, is to double click this to initiate your sync. Alternatively, you could setup a crontab on a Linux system, or a Schedule on Windows to automatically run the system for you, thus eliminating your need to worry.

The other great thing is that you can run this on multiple machines. I have a desktop and a laptop, but this isn't a problem as Unison is bi-directional. As soon as those new files from the laptop hit Dropbox, they will be downloaded onto my Desktop and, when I run Unison at home they will be re-synced back into my file system there. This has the additional advantage of everything being backed up in triplicate; it can withstand two points of failure (my laptop and desktop being stolen, my laptop being stolen and Dropbox being compromised etc.)

While this may seem fairly complex, it's a one-time setup procedure that you can then simply use indefinitely. It is, however, not strictly an adequate backup on its own as you could still accidentally delete a file and then synchronize. Therefore, in a follow-up post, I will be examining ways you can script yourself an adequate backup.