Backing up your Firefox Config in a .dotfiles repo
DISCLAIMER: Spare yourself from my suffering and don't actually follow this guide. It is incredibly autistic; setting this up is needlessly difficult.
Ever since I started using Linux and dived into using tilling window managers, I have learned how to backup every single configuration file that I have ever modified or written into a ~/.dotfiles repo. The tilling window manager part really helped me to make a repo, but it wasn’t something necessary because I am using KDE Plasma now and I still manage my config files in a git repository. What I love about this is that, not only can I save all of my work and switch computers having my configs like it was in seconds, but it a also gives me complete sovereignty, I do not need to rely on anyone to backup my config files for me, like a Firefox account or something.
Well, almost every single config file apart from browser, profiles/config. For some reason, arguably one of the most important pieces of software one has on his computer’s config files are a complete utter mess to backup. In my case, I’ve been using Firefox/Firefox forks for a very long time, before even considering using Linux on my main desktop computer.
I really don’t understand why does Firefox profiles are the way they are, taking the example of LibreWolf (it stores the config at ~/.librewolf
whereas the default Firefox is ~/.mozilla/firefox
I think but I’m not sure): by default, when you first open the browser after installing it, or if you delete ~/.librewolf
, it creates a folder name (random).default
and (random).default-default
inside it, where .default-default
is the folder where your default profile is stored, and .default
that does apparently nothing for some reason. It is really weird, the randomness part was the thing that kept me from making a git repository simply because, well how would I do it if it is random? It would just not work at all.
Well turns out there is a way to change that, making it possible to add your Firefox config into your dotfiles repository! For that I would recommend installing a fork of Firefox like Mercury or LibreWolf because you will need to delete your profiles to actually migrate/save your config in a dotfiles repo, well technically you don’t specifically need to delete but I kept deleting and relaunching my browser and asking ChatGPT which files I should save, but I still recommend doing this on a clean install of Firefox because it is easier to navigate I guess.
To change the way that profiles are generated and used there are two .ini files that you will have to change inside the Firefox profiles folder: profiles.ini
and installs.ini
. Here are mine:
profiles.ini
1[Profile0]
2Name=diowo
3IsRelative=1
4Path=profile.diowo
5Default=1
6
7[General]
8StartWithLastProfile=1
9Version=2
10
11[Install6DB62B9939B8ED51]
12Default=profile.diowo
13Locked=1
installs.ini
1[6DB62B9939B8ED51]
2Default=profile.diowo
3Locked=1
What does *6DB62B9939B8ED51 do? I don’t know, I’m assuming that yours is different, so just modify this to look +- like mine. When modifying, close the browser and then delete everything inside the profiles (rm -rf ~/.librewolf/ or your browser’s config folder) folder keeping only the .ini files.

Now, when you open your browser, a folder with the name you chose should appear. This makes it soo much easier to back up in a .dotfiles repo… I personally would like to store: my preferences in about:config, bookmarks and favicons, extensions, userChrome.css and search engine preferences, I wouldn’t like to store any cookies for obvious reasons or anything else really, this way I can sort of sync my Firefox config across my devices, maybe, although less seamlessly than with a Firefox account but moving away from it is what I want most.
Now the actual configuration. Firefox and I’m also assuming Chromium profiles folders (the actual profile now like profile.diowo I just showed) stores configs in the most autistic way possible:
-
chrome/: this is the folder where userChrome.css is stored: completely optional, modifies the look of Firefox: heres a video.
-
extensions/: this is where your extensions .xpi’s are stored, it should auto update, I’m pretty sure so no worries there
-
addons.json, extension-settings.json, extensions.json: all probably related to extensions: I am not sure if it is necessary to back them up, but because of the autistic way that Firefox stores configs, I’ll back them up too.
-
favicons.sqlite: I don’t know how favicons are stored in an sqlite database but they are, I recommend saving this because by default, your bookmarks will not load with favicons, and you will have to re-open every bookmark so that Firefox can go and download the favicons again.
-
places.sqlite: this is where your bookmarks are stored
-
prefs.js: this is where your about:config is stored and it’s probably the least autistic way things are stored
-
search.json.mozlz4: this weird file is where your search engine preferences are stored, I really want to know why it is named horribly like this

You will now have to copy these files I just mentioned to your dotfiles repo relative to your new, (clean: preferably fork) of Firefox’s folder profile location. It is weird to explain but if you’re used to dealing with dotfiles you probably understood what I meant. I personally like to use GNU Stow to manage my dotfiles and you can find a good video about here. I put all of my dotfiles in a git repository inside the folder src/
, It looks like this:

Now, you will also need to add some things to your .gitignore
file to ignore everything that is not what I specifically mentioned above:
1/src/.mercury/profile.diowo/*
2!/src/.mercury/profile.diowo/extension-settings.json
3!/src/.mercury/profile.diowo/extensions.json
4!/src/.mercury/profile.diowo/places.sqlite
5!/src/.mercury/profile.diowo/prefs.js
6!/src/.mercury/profile.diowo/search.json.mozlz4
7!/src/.mercury/profile.diowo/chrome/
Now in my case I would just cd in my git repo and issue some commands:
1rm -rf ~/.librewolf # (or your fork's folder)
2git add .
3git commit -m "add firefox config"
4git push
5stow --adopt -t ~ src/
6git restore .
As you probably saw before I also like to add the folder native-messaging-hosts
to my dotfiles repo, well I only use this for the integration with KeePassXC, inside this folder is a config file named org.keepassxc.keepassxc_browser.json
:
1{
2 "allowed_extensions": [
3 "keepassxc-browser@keepassxc.org"
4 ],
5 "description": "KeePassXC integration with native messaging support",
6 "name": "org.keepassxc.keepassxc_browser",
7 "path": "/usr/bin/keepassxc-proxy",
8 "type": "stdio"
9}
I think that’s enough for you to make your own dotfiles with Firefox. I would show my dotfiles repository but I have set it to private because I am not sure how much private information is there, I assume it’s fine but I don’t want to take the risk.
Saturday, October 21, 2023