Sunday, January 16, 2011

Sharing Thunderbird Address Books Between Computers with Dropbox

In the previous post I described how to synchronize your Thunderbird signature (file) across computers using Dropbox.

This was a fairly easy task, because Thunderbird let's you specify the signature file as an absolute path, so you can put your signature anywhere on your computer.
For whatever reasons, the address book has to reside in your profile folder.
So if you want to synchronize Thunderbird address books across computers using Dropbox, this is a bit more tricky.

First, we have to somehow have the address book file in the "My Dropbox" folder, and still in the profile folder.
Luckily, Windows XP (and later) do have links in the NTFS filesystem - contrary to what most people think/know.
Technically they are called NTFS junction points, but usually referred to as links.
You can create them with the FSUTIL utility.

So what we'll do is.
  1. Find the "master" address book
  2. move it to the Dropbox folder
  3. replace the original file in the profile folder with a link to the file in the Dropbox folder
  4. repeat step 3 for all computer.
So, assuming you already did register for Dropbox and install it, here are the details:
    1. In Thunderbird check the name of he address book you want to synchronize. In the Address Book window, select the address book of your choice and then properties. The only property there is the name.
    2. In the Config Editor, locate the file name for your address book. This can easily be done if you filter the view on "ldap_v2.servers.*.descr". This will list all the address book names you have, including the one we are looking for (from step #1).
    3. Find the id of your address book.
      It is is right behind "ldap_2.servers.".  Something like "pab" or "default".
    4. Once you have that identifier, you can get the file name from "ldap_2.servers.yourid.filename". It is most likely abook.mab. [1]
    5. Then locate your Thunderbird profile folder.
      This is (as a default) in the Thunderbird folder of your personal Application Data directory. The fastest way to get there is via Windows Start MenuRun → "%appdata%" (literally with the percent signs). Then go to Thunderbird, then Profiles and then pick the profile you want to modify (if you have more than one).
    6. Now find the file from step #4.
    7. Be sure to exit Thunderbird now, so that all files are closed and available to you.
    8. Move the file from step #6 to your "My Dropbox" folder (again, this can be easily opened by double clicking on your Dropbox icon in the task bar).
    9. Open a command line (StartRun → "cmd.exe" ) and change directory to your profile folder form step #5.
    10. Find the "My Dropbox" folder in your file system. It's quite close to the Application Data folder. Try something like a "dir %homepath%\abook.mab /S /B" to find the exact location of the file.
    11. Create the symbolic link with the following command:
      fsutil hardlink create abook.mab "..\..\..\..\My Documents\My Dropbox\abook.mab"
      Before you do this, you might want to check with dir, if the abook.mab file can really be found with the above path. Correct your path as appropriate. You can also use the absolute path from step #10.
    12. With a "dir abook.mab" verify that the "logical" file is back again with the correct size.
    13. Start Thunderbird and verify that your address book is available and correct.
    14. Go to computer #2 
    15. Repeat steps #1-12 as above, just do not copy the abook.mab (or whatever the name is) to the Dropbox folder. Only delete (or rename) it in the profile folder, before your create the link with fsutil.
    16. When you start Thunderbird you should now have all the addresses from computer #1 available.
    17. Repeat #15 for all remaining computers

    I haven't been using this method for long, so I can't really say how stable this works, especially if there are "replication conflicts", i.e. when you update the file on both computers before Dropbox has a chance to synchronize. Should there arise major problems with my setup, I'll post them here.

    Comments section is of course open for your findings.

    [1] in the following paragraphs I will - for brevity - only call it abook.mab; please substitute your file name as appropriate.


    Bernhard said...

    Thank you for this great info.

    I tested this on two Macs. Works great. The only thing I noticed was that Thunderbird updates the address book (in the dropbox folder) only when you exit the application.
    Also, the updated address book is not made current on another computer while Thunderbird is running on that machine (although the updated dropbox file is there).

    Once you quit and restart Thunderbird the updated data is all there.

    On a Mac it's very easy to make symbolic links with a free application called "Symbolic Linker".

    Thanks again


    Bernhard said...

    Hi, Roman,

    I tried to do it on a PC running Widows XP (via Parallels on my Mac).

    I created the hardlink using your description using fsutil.

    When I open Thunderbird on the PC I get the updated (and Dropbox-synced) address book information from my Mac.

    But changing any information on the PC address book does not trigger a sync from Dropbox.

    The same holds true for any subsequent changes on another computer. When I change address data on the Mac the updated address book in the Dropbox folder is not recognized by Thunderbird on the PC.

    It's like the connection between the hardlink and the dropbox file gets lost.

    Any ideas?



    Roman said...

    Hi Bernhard,
    thanks for your comments; see my response (partly) here

    Bob on Whidbey said...

    In my TB v 24.6.0 the filter ldap_v2.servers.*.descr needs to be replaced with "ldap_2.servers.*.descr"

    Roman said...

    actually, Bob, you just pointed out a typo, it should read ldap_2 anyway.

    Bob on Whidbey said...

    This technique only worked one time for me. TB correctly picked up the abook.mab file from my Dropbox account. When I closed TB, it overwrote the link file with the complete abook.mab file. Thus, any changes made in abook were not written to the Dropboox version of the file, but instead were written to the new version under Profiles.
    I'm using Win7 on on pc and Win8 on the other and TB 31 on both.

    G. Stewart said...

    This is something I've been looking for for a while now and it works a treat!

    Completely forgot that NTFS allows for hardlinks, d'oh!

    JFTR, TB 45 doesn't seem to exhibit the same problem as "Bob on Whidbey" had above. Rather than clobber the local .mab file (thus severing the link to the file in your DropBox/Google Drive/OneDrive/whatever) it looks like it opens the file in write mode, truncates it and fills it with new contents.