Rolling your own cloud storage with Unison

Cloud storage is a very cool way to back up files, but it has two major drawbacks:

  1. If you back up everything, it will cost you a bit for the space.
  2. You need to trust that the company wont lose, tamper with, or leak your files.

I’ve recently discovered a little program called Unison, which provides a bandwidth-efficient way to synchronise folders on two computers, solving both of those problems. It has clients for just about every platform, it’s open source, and it’s been around for over a decade.

I’ve set up a copy of my laptop’s home directory on my desktop computer, so if it ever explodes, I can just sync it back:

With most ISP’s offering static addresses, you could even put a NAS on the internet to sync with, which would basically be a home DropBox.

Laptop and desktop example

Unison is in most Linux distributions. On Debian or Ubuntu, you can install it with:

apt-get install unison

mikebook has a profile called mikebox.prf, located in /home/mike/.unison/, which tells it to keep a copy of its home directory on mikebox.

root = /home/mike
root = ssh://mike@mikebox//home/mike/Remote/mikebook/
ignore = Name .*
ignore = Name *.iso
ignore = Name *.img
ignore = Name unison.log
ignore = BelowPath Downloads
ignore = BelowPath workspace

Everything can be brought up to speed with:

unison -batch mikebox

If mikeboox is running out of space, then I can drag files out of Remote/mikebook to somewhere else, and they simply vanish from the laptop next time it is synchronised.

Notes

  • Remote paths require that extra / in the filename.
  • Hidden folders seem to be skipped, so keep a copy of your .prf file in case you blow up your computer.

Leave a Reply

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