Posted on

Intro

Today Firefox started with no tabs opened. I used to have a lots of them opened. Just for convenience. It’s just simpler that way. At least for me. Email, calendar a couple of DIY sites, dozens tabs with music from YouTube, some articles opened for later reading. All gone. Must admit - seeing your browser started without usual carp ton of tabs is a terrifying experience. I know, hoarding tabs is a problem, and I solve it eventually, but for now I have more urgent task to do. Browser history was intact, bookmarks too. Extension buttons - in place, but of them work. Well, profile is partially borked and I need to extract all data possible and migrate it to a new profile.
But first…

What is Firefox profile

Any modern browser has this feature called profiles. Each profile is fully separated set of preferences, bookmarks, history, extensions and other personal data. To start working with profiles you need to access its Firefox Profile Manager. Start a browser with -p command line option:

firefox -p

This will cause Firefox to show you this window, where you can manage available profiles.

Firefox profile manager window

Firefox profile manager window

Take a note buttons on left of the window. They do exactly what the name say: Create, Rename and Delete a profile. Start Firefox button will start browser with selected profile. Use selected profile… checkbox, when set, will mark profile as default. Browser will open it every time, when started without any options.

Where to find

By default, profiles located in your home directory. Under Windows path will be %APPDATA%\Mozilla\Firefox\Profiles, under Linux - ~/.mozilla/firefox. It’s possible to have profile elsewhere, though, but this requires messing with profiles.ini or a command line.
You can also check location of your active profile by typing about:support in URL bar and finding Profile Directory row. The Open Directory button will open current profile directory for you.

Firefox about:support tab

Firefox about:support tab

It appears, you can choose a directory while creating a new profile. In a step, when Firefox asks for profile name, there is a button called Choose Folder that allow you to, well, choose a directory for a new profile.

Useful files

Ok, profile directory found. What's next?
Directory holds all variety of different files. Some of them contain bookmarks, opened tabs and history. I need them rescued. Others - can be ignored and brought to a digital oblivion. So, which file is which?

A word of caution:
Create a copy of ~/.mozilla/firefox directory now. Better to have a copy at hand, if needed.

History and Bookmarks

  • places.sqlite
    SQLite. Contains bookmarks, download lists, browsing history.

  • favicons.sqlite
    SQLite. Contains favicons from visited sites.

  • formhistory.sqlite
    SQLite. Form auto-complete history.

  • bookmarkbackups/
    Directory. Contains a versioned backup of your bookmarks in jsonlz4 format.

Extensions

  • extensions/
    Directory. Contains all installed extensions.

  • storage/default/
    Directory. Contains local storage data for websites and some extensions.

Session

  • sessionstore.jsonlz4
    Open tabs are stored here. In order this file to exist Firefox needs to be shut down properly. It won’t be created if browser crashed or killed.
    If you can't find this file - sessionstore-backups/ directory is your best bet. Copy the most recent backup file to a profiles root directory as sessionstore.jsonlz4 and try launching a browser again.

  • sessionstore-backups
    This directory contains automatic backups of your session in jsonlz4 format.

Browser preferences

  • prefs.js
    Current Firefox settings. Any changes done both in browser options and about:config will be stored here.

  • user.js
    Your can store your custom preferences here. The catch is that any options added to this file will override defaults or options from prefs.js. This is a good way to keep custom configuration separated and apply it at once just by copy-pasting a file to a new profile. You can get more related info in this MozillaZine KB article.

Securty

  • key4.db and logins.json
    Responsible for storing your logins and passwords. Both are encrypted. Both must be copied to the new profile to be decrypted properly.

  • permissions.sqlite
    SQLite. Site-specific permissions. Disabled video autoplay, declined notification request and other. Copy it just to avoid being annoyed again.

  • cookies.sqlite
    SQLite. Your cookie jar.

  • cert9.db
    Imported certificate storage.

Other

  • search.json.mozlz4
    mozlz4. Search engine configuration.

  • persdict.dat
    Personal dictionary for a built-in spell checker.

New beginning

So...
Create a new profile...
Copy all necessary files there. Then, start a browser and...
It started with all tabs, bookmarks and history in place! Yay! Recovery mission successful! I'll reinstall add-ons later.
For now, I'll mark new profile as default and call it a day.