How to Backup and Restore Firefox Profile On Linux

We recently published an article on how to backup and restore a Google Chrome profile on Linux, now, our concentration is on Firefox.

Like I did in the Chrome article, I’ll list the steps required to backup and restore your Firefox Profile. The listed commands are for you to copy and paste in your terminal after you may have edited them to suit your needs e.g. your preferred directory path. None of the terminal commands requires root access.

A backup of your Firefox profile enables you to save all your browser data (extensions, history, settings, etc.) on your local machine or any other storage medium so that you can restore it at a later time in case of a system failure, fresh installation, or migration. What’s cool about this method is that you don’t need to be connected to the Internet.

Firefox Profile Backup

1. Launch your terminal and navigate to the ~/.mozilla directory from your home folder with the following command.

$ cd ~/.mozilla

2. Use tar command to compress your entire ~/.mozilla directory into a GZip archive with the following command.

$ tar -jcvf firefox-browser-profile.tar.bz2 .mozilla

3. Once the compression is complete, move the archive file to any safe location of your choosing. This time around, let’s move the archive to the desktop folder.

$ mv firefox-browser-profile.tar.bz2 ~/Desktop

That’s it. You can now back the profile archive to secondary storage devices or your preferred cloud service to restore it whenever.

Firefox Profile Restore

1. Remove entire Mozilla’s configuration directory.

$ rm -rf ~/.mozilla

2. Next, unzip the ~/.mozilla folder in your home directory with the following command:

$ tar -xvf firefox-browser-profile.tar.bz2

Now you can run Firefox with all of your bookmarks, history, extensions, etc. back in place.

Encrypt Firefox Profile Backup

You already know by now that it is important to back up your profile with encryption because it restricts your data to you and users with the key as the file will be virtually useless to anyone without the rights to decrypt the archive.

It takes a couple more steps to complete but we can easily complete them with GnuPG. If it’s not installed, you can install it using following command.

$ sudo apt install gnupg  [On Debian/Ubuntu]
$ sudo yum install gnupg  [On CentOS/RHEL]
$ sudo dnf install gnupg  [On Fedora]

After you have created the backup, enter the following terminal command from the directory containing the backup.

$ gpg -c firefox-browser-profile.tar.bz2

Enter a secure password when gpg -c prompts you for one. Once done with the encryption, save the firefox-browser-profile.tar.bz2.gpg file and delete the unprotected firefox-browser-profile.tar.bz2 file.

You can decrypt the archive at any time with:

$ gpg firefox-browser-profile.tar.bz2.gpg

Do you have any comments or questions to contribute? Drop them below in the comments section.

Divine Okoi is a cybersecurity postgrad with a passion for the open-source community. With 700+ articles covering different topics in IT, you can always trust him to inform you about the coolest tech.

Each tutorial at GeeksMint is created by a team of experienced writers so that it meets our high-quality writing standards.

6 thoughts on “How to Backup and Restore Firefox Profile On Linux”

  1. Open FF, open the menu -> help -> more information for error finding (I don’t know what it is named in English, I use a different language) and find your actual profile folder in the table below.


    You only have to copy $somewierdstuff somewhere, not the whole Mozilla folder.

    I collected 6 profiles over the past 2 years, each of it 100 MB worth. Nobody needs those old profiles.

  2. I immediately get an error in xubuntu 18.04

    cmcanulty@ubuntu1:~$ cd ~/.mozilla
    cmcanulty@ubuntu1:~/.mozilla$ tar -jcvf firefox-browser-profile.tar.bz2 .mozillatar: .mozilla: Cannot stat: No such file or directory
    tar: Exiting with failure status due to previous errors

  3. One can, of course, simply copy the Firefox profile to anywhere in the file system, and subsequently back it up in normal backup operations. I don’t compress or encrypt ANYTHING in a backup because quite frankly I do not trust either compression or encryption algorithms to be coded properly by some unknown programmer of unknown capability. I have heard and read about both types of algorithms being corrupted and failing during restore or even normal operations and believe it is foolish to use them in critical backups.

    • So true! Deja Dup has failed me during a critical restore op. Luckily, I had also backed up my entire data (normal copying) to another external drive. Saved my bacon. Though I was in a cold sweat when it happened 😉

      I can’t emphasize how important B.Ups are and everyone should have a plan, because that day will come, sooner or later…


Got Something to Say? Join the Discussion...