I recently got a laptop to use for web development work when I
travel. I wanted a simple way to sync up the data between it and my
Desktop computer so that they would both have the same bookmarks,
emails, instant message logs, etc. Along comes unison to save the day.
It ended up being MUCH easier than I expected.
Both computers are running Ubuntu 7.10 “Gutsy Gibbon” and are connected
to my router–the Desktop is hard wired (Ethernet) and the laptop uses
a WiFi connection. The desktop will be running an SSH server which will
be used by Unison on the laptop to synchronize the folders of my
choosing. The laptop will initialize the sync through a unison GUI:
gtk-unison
- Configure Desktop Computer
- Configure Laptop Computer
- Synchronize Data
The laptop will be connecting to the desktop over an SSH (secure
shell) connection. Moreover, I’ll be able to connect to the desktop
from my laptop and browse/copy any files I need.
First, I changed the desktop computer’s “Host Name” to something
that makes sense in the ‘Network Settings’ dialog (‘System’ >
‘Administration’ > ‘Network’). I used “Desktop”.
Next, I installed the necessary software on the desktop:
sudo aptitude install openssh-server unison
Then, I configured the SSH server so that my user “micah” could log
in over an SSH connection and that root login was NOT allowed. I did
this by editing ‘/etc/ssh/sshd_config’. I changed:
AllowRootLogin yes
to:
AllowRootLogin no
And then I added:
AllowUsers micah
And finally, restarted the SSH service:
sudo /etc/init.d/ssh
The desktop computer already has all the data I need the computers
to share. However, there is one “gotcha” for Mozilla products. They use
a random folder name for you profile. I’m going to want this to be the
same so that both computers versions of Firefox and Thunderbird share
data.
For Firefox I renamed the profile folder in .mozilla/firefox to
‘micah.default’ and edited .mozilla/firefox/profiles.ini to reflect
this change. I did the same thing in .mozilla-thunderbird/ for
Thunderbird–my email client.
On the laptop, I first installed all the software that will be
sharing this data. For me, this was Firefox, Pidgin (formerly gaim),
Thunderbird, MySQL Query Browser, and gFTP. Next, I renamed the
profiles for Mozilla products as described in the previous section.
Finally, I installed unison and it’s graphical user interface:
sudo aptitude install unison unison-gtk
The unison program will now be available from ‘Applications’ >
‘Internet’ > ‘Unison’, however, we’ll need to setup a profile to
tell unison what to synchronize. We can do this with a profile file.
I’m going to create one called “Desktop” by creating a text file in
~/.unison as follows:
mkdir ~/.unison
touch Desktop.prf
gedit Desktop.prf
There are numerous ways you can setup your profile. The easiest way
would be to simply sync up the entire home folder, however, I have a
LOT of data in my home directory and don’t want it all synchronized.
Furthermore, my desktop is an AMD64 architecture while my laptop is
i386 which will cause problems with Firefox/Thunderbird if they share
extensions and plugins. I need to share ONLY the data.
Here’s my Desktop.prf file. The comments should let you know what’s going on:
### ROOT SYNC PATHS ###
# first root is my home directory on this laptop
root = /home/micah/
# second directory is my desktop's home folder over SSH
root = ssh://micah@192.168.1.2//home/micah/
### PATHS TO SYNCHRONIZE ###
# sync all of my email data (will ignore parts later)
path = .mozilla-thunderbird/micah.default/
# only sync up bookmarks for firefox
path = .mozilla/firefox/micah.default/bookmarks.html
# sync all gFTP for the bookmarks and cache
path = .gftp/
# gaim/pidgin IM client logs and settings
path = .purple/
# MySQL Query Browser information and history
path = .mysqlgui/
# Personal folders
path = finances/
path = websites/
path = projects/
path = robotics/
path = email_signature
### IGNORE RULES ###
# ignore archived backups
ignore = Path websites/archive/*
# ignore the extensions folder in thunderbird as they are architecture-specific
ignore = Path .mozilla-thunderbird/micah.default/extensions/*
# I don't think these will break anything, but let's ignore anyway
ignore = Path .mozilla-thunderbird/micah.default/compatibility.ini
ignore = Path .mozilla-thunderbird/micah.default/install.log
Now, I can run Unison and select my “Desktop” profile. I do this
before leaving on a trip with my laptop and then again when I return.

