Friday, May 8, 2009

Synchronizing multiple computers

For 20 year I had only one computer, a laptop and later a tablet. I like the slate tablet from Fujitsu Siemens, because it lets me arrange screen and keyboard as I like it. Unfortunately, it is heavy and the batteries run out quickly, thus I have added a Asus eeePC 901 “for the road” - ending up with three machines: a tablet at home, a table at work and the eeePC anywhere else.

Synchronizing the three computers became crucial. I regularly missed a file needed, because it was stored on another machine, and I had to repeat any change to the interface I made.

Synchronizing the files I work on was easy: Unison does it. I set up a directory on a machine on the web (computer number 4!) and I sync each of the three machines I work on against the fourth one. Unison works reliably and points out files which have a conflict and need manual (human intelligence) resolution. But still, every change to a setup in an application had to be redone on the other machine... maddening!

When I upgraded all three computers to Ubuntu 9.04 Jaunty I set them up with exactly the same software and then decided to synchronizing all my files – including the hidden files describing my configuration and user preference using Unison. The unix-style operating system separates the setup of the computer (which is evidently different for each hardware) from all user specific aspects, which are stored under /home/user_name. This works!

As an added benefit, the files I have on computer number 4 are automatically backed up every night (with rdiff-backup, keeping all old copies). This is sufficient for retrieving previous copies of files; a backup of the installation is not needed, because it is faster to re-install all, which takes less than 2 hours, including installing additional software and the one or two edits necessary.

To reduce traffic on the web, I excluded all “cache” type files and try to find the files which are specific and must remain different on the three machines. The file with the list of path and filenames to ignore when synchronizing is included here at the end with the hope that I may get some hints what I should add or rather what I must synchronizing to avoid disasters.

I guess others may have similar needs - having all your files and setup all the time available is what Google and Microsoft try to sell. To make it a reality under my full control, the software designers should think of
1. all cached data in files or directories called 'cache' and not rely blindly on the reliability,
2. configuration in small files, easily shared,
3. allow local configurations (and other data needed per machine) in files or directories called 'local' (or with names including the hostname).
It should be possible to have a live system on a stick, which you can plug into any reasonable computer, start up, sync and have most of your files locally to work with.

For things which must be different on different machines, I use scripts I with a case statement as shown here:

#!/bin/sh
# to execute depending on the host

p904Atlanta () {
unison -sshargs "-o ProtocolKeepAlives=30" gi41_mergeAtlantaBern
exit 0
}

p904Bern () {
unison -sshargs "-o ProtocolKeepAlives=30" gi41_mergeAtlantaBern
exit 0
}

p904Hamburg () {
unison -sshargs "-o ProtocolKeepAlives=30" gi41_mergeHamburg
exit 0
}

THISHOST=$(hostname)

case $THISHOST in
bernJ) p904Atlanta;;
atlantaJ) p904Bern;;
hamburgI) p904Hamburg;;
*) echo unknown host $THISHOST;;
esac

The list of files excluded for Unison:
ignore = Path .unison/*
ignorenot = Path .unison/*.prf
ignorenot = Path .unison/*.common

ignorenot = Path .nx
ignore = Path .nx/*
ignorenot = Path .nx/config

ignorenot = Path .svngzPrefs.txt

ignore = Path .beagle
ignore = Path .cache
ignore = Path .cabal
ignore = Path .eclipse
ignore = Path .evolution
ignore = Path .mozilla-thunderbird
ignore = Path .popcache
ignore = Path .wine
ignore = Path .nautilus
ignore = Path .thumbnails

ignore = Path .xsession-errors
ignore = Path .pulse
ignore = Path .ICEauthority
ignore = Path .Xauthority

ignore = Path .dbus
ignore = Path .config/transmission
ignore = Path .opensync*
ignore = Path .ssh/ida_rsa
ignore = Path .gnome2/gnome-power-manager/profile*
ignore = Path .gconfd/saved*
ignore = Path .recently-used.xbel

ignore = Path {unison.log}
ignore = Path {local_*}
ignore = Path Photos
ignore = Path {workspace}
ignore = Path {experiments}

#avoid temp files
ignore = Name temp.*
ignore = Name .*~
ignore = Name {*.tmp}
ignore = Name theResult
ignore = Name *cache*
ignore = Name *Cache*
ignore = Name cache*
ignore = Name insertedRepo_*

ignore = Name trash
ignore = Name .trash*
ignore = Name Trash
ignore = Name *Trash*
ignore = Name *trash*

ignore = Name urlclassifier*

perms=0o1777

No comments:

Post a Comment