How to keep two Mozilla profiles in sync

Introduction

I love Mozilla and use it both at home and at work. So I have my bookmarks, newsgroups, cookie permissions, address book, etc on two different PCs. So adding an bookmark at work means that you cant see it home and reading a newsgroup posting at home means that it is unread at work. This is very annoying!

That’s why I decided to get some kind of synchronization going. I wanted to be able to keep the two Mozilla profiles, the one at home and the one at work, in sync.

Windows

I use Windows. So most of this information and the solution only works on Windows. The same solution could however be made to work on Linux or Mac.

Roaming profiles

All of this wouldn’t matter if Mozilla supported roaming profiles – see bug 124029. Currently it doesn't. So until Mozilla gets roaming profiles we have to do it in another way. Roaming profiles is a way to store profile data on a remote server. Netscape 4 had roaming profile but its support was not very usable. For example information about which news postings you had read wasn’t copied.

Mozilla and profile data

Mozilla stores all profile information such as bookmarks, cookies, certificates in the profile directory. Basically all of the settings you can change in the preferences are stored inside the profile directory. This is very nice. It makes backing up a easy thing. Just take a backup of your profile directory, minus the cache directory and you're home free. Most of the files are in plain text. All of this makes the synchronization a bit easier.

Microsoft Outlook and Outlook Express on the other hand stores profile data in weird places inside the registry and in some files scattered around in different places.

Location of the profile

The Mozilla profile is usually located in the Application Data directory. On Windows the profile data is per default located in:

%USERPROFILE%\Application Data\Mozilla\Profiles\[profile name]\[random string].slt\

On a English Windows 2000/XP that's normally:

C:\Documents and Settings\[Windows Login Name]\Application Data\Mozilla\Profiles\[profile name]\[random string].slt\

Profile store

The path to all the profiles used by Mozilla is located inside a file called registry.dat, which can be found in the Application Data folder under the Mozilla directory. This is usually:

C:\Documents and Settings\[Windows Login Name]\Application Data\Mozilla\

The registry.dat file is currently in a binary format so editing it is a bit tricky but it can be done. Hopefully bug 174522 will be fixed someday.

For more information about how to find your profile please turn to http://gemal.dk/mozilla/files.html#path

My Mozilla setup

Before we go into the details about how the synchronization works I'd like to describe my Mozilla setup:

All my mail is located on IMAP servers.

I use Mozilla at home and at work.

I’ve setup a Mozilla profile on my home and work PC with identical mail and news account info.

I use Windows and 4NT as command shell.

I use the same profile location c:\private\mail\mozilla\gemal on both PCs.

Two working solutions

There are two ways of getting the profile synchronization working.

Use the same profile location on both PCs

Don't use the same profile location on both PCs

If you want to synchronize all your settings in your profile you have to go with solution number 1. This involves copying the prefs.js file. This file contains some absolute paths, like where where your signatures are located and where your mail and news is stored (bug 137006). Also remember to exclude the cache directory (bug 74085)

If you just want to copy some of the settings like bookmarks, newsgroup settings and certificated you can go with solution number 2.

Solution 1: How to get same profile location on two PCs

This is the really advanced part. Getting Mozilla to store the profile in a specific folder is not easy. Currently it's not possible to override the addition of the “random.slt” part of the profile location. Not even from the command line. This is really really stupid. And since the registry.dat file is in binary format, it's difficult to change the location of the profile.

To create a profile in a specific location from the command line use the following syntax:

mozilla.exe -CreateProfile “test c:\private”

This will create a profile called test in the c:\private directory. This will however still add the random.slt to the c:\private\ directory, so that the actual profile will be located in something like “c:\private\irhj8bx0.slt\”.

The trick is to create the profile in a dummy directory that when you concatenate it with the random.slt name sums up to the same length as the desired directory name length. Something like:

c:\xxxxx\irhj8bx0.slt

c:\private\mail\gemal

So I needed the profile to be located in “c:\private\mail\gemal”. The random.slt is 8 + 1 + 3 chars. A total of 12 chars. “c:\private\mail\gemal” is 21 chars. So I need to create a dummy directory of 21 – 12 = 9 chars. Something like “c:\xxxxx\”. This will produce an entry in registry.dat with the appropriate length:

c:\xxxxx\irhj8bx0.slt

So I ran

mozilla.exe -CreateProfile “gemal c:\xxxxx”

Warning: The directory in the -CreateProfile argument must not end with “\”. So don't do “c:\xxxxx\”.

This created a Mozilla profile called gemal in the c:\xxxxx\ directory. So far so good.

Then I used UltraEdit to manual hex edit the registry.dat file and changed

c:\xxxxx\irhj8bx0.slt

into

c:\private\mail\gemal

This was no problem since the two strings had the same length. Remember to back up the registry.dat file before doing this.

Then I created the directory “c:\private\mail\gemal” from the Windows Command Prompt. Next launch Mozilla and some Mozilla configurations files should appear in the “c:\private\mail\gemal” directory. You now have a Mozilla profile in a directory of your own choosing. Now do the same thing on the other PC.

The random.slt directory is added as an security measure to protect against viruses etc that could somehow try to use some naming conventions to find your profile directory.

Solution 2: Ignore profile location

If you don't want or don't have the two profiles in the same location on the two PCs there are some limitations in the files which you can synchronize. The limitation lies in the files that contains absolute paths. This includes:

panacea.dat

prefs.js

secmod.db

There could be other files as well. For a description of these files please turn to http://gemal.dk/mozilla/files.html.

How to keep the profiles in sync

I use a small homemade 4NT batch script called xfer, which basically copies files to and from an FTP server. The script reads a file which contains the full path of the files you which to transfer. The script can do two things. Sending files to an FTP server and retrieving files from an FTP server.

So the procedure of using the script is this:

Just before I close my PC at home I do “xfer up”. This uploads my Mozilla files from my home PC to an FTP server.

When I arrive at work the first thing I do is “xfer down”. This downloads my Mozilla files from the FTP server to my work PC.

And just before leaving work I do “xfer up”.

And just after turning on the PC at home I do “xfer down”.

I think you get the picture now.

Which files do I copy back and forth?

abook.mab

bookmarks.html

chrome\usercontent.css

cookperm.txt

mailViews.dat

news\*.rc

For a complete listing of all the files inside your profile directory please turn to http://gemal.dk/mozilla/files.html which also has a description of all the files.

You could transfer more files like cookies.txt, downloads.rdf etc. It's all up to you.

Advantages

The big advantage is that my Mozilla profiles are kept in sync. Having to maintain two different sets of bookmarks is a pain. Having to read the same news postings at work and at home is just a plain waste of time.

Disadvantages

The big disadvantage is that I have to remember to do “xfer up” before I shutdown and “xfer down” before launching Mozilla. I sometimes forget this. This could cause lose of bookmarks etc if I'm not aware of the problem. But I haven't lost anything yet.

It's also difficult to setup the profile locations. Perhaps this be be easier if some of the mentioned bugs get fixed.

Author

My name is Henrik Gemal and I'm the QA on the Mozilla installer for Windows. I have been using Mozilla for years now and still love it.

I maintain a blog about Mozilla at http://gemal.dk

Version information

13. Mar. 2003 - First draft

17. Mar. 2003 - Fixed my spelling thanx to Timeless

20. Mar. 2003 - Released

How do you keep two Mozilla profiles in sync	20. Mar. 2003

http://gemal.dk	Page 4 of 4

How do you keep two Mozilla profiles in sync

Henrik Gemal

2003-03-10T17:08:00