1. Home
  2. Linux

How To Backup And Restore A Firefox Profile On Linux

Firefox is a great browser, especially if you care about open source, software freedom, and the open internet. Despite all of the nice things that can be said about Firefox, there are still some minor annoyances that exist. The single biggest one is that there still isn’t a native way to back up and restore a Firefox profile. Instead, they insist users use “Firefox Sync”.

SPOILER ALERT: Scroll down and watch the video tutorial at the end of this article.

Firefox Sync is nice, especially when setting up the browser on multiple computers. The trouble is, it doesn’t have the ability to save a profile that exists, and will only download data to a new one. This is extremely annoying if you just want to avoid sync, keep everything and restore it later.

Luckily, with a little know-how, it is possible to back up a Firefox Profile via the Linux terminal.

Back Up Firefox Profile – Terminal

The Firefox web browser stores all profile information directly in ~/.mozilla, in the home directory, for each user. To back it up, you’ll first need to open up a terminal window and use it as a normal user. Do not try to gain a root shell during this process, as it’s very likely any backup archives you make could be owned by the root user and not regular ones. To create a simple Firefox backup, first, close the Firefox browser. After that, go to the terminal and enter the compression command.

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

Tar will compress any files inside of ~/.mozilla and output firefox-browser-profile.tar.bz2. When the process is done, you have a basic, unlocked backup of Firefox. Feel free to put it on your NextCloud server, Dropbox account, external hard drive and etc.

Note: if you choose not to encrypt your Firefox profile Tar archive, keep in mind that you are making yourself vulnerable. Anyone that gets their hands on the firefox-browser-profile.tar.bz2 archive can extract it, restore it and open up Firefox. From there, they can access passwords, history, email addresses, credit card information, etc.

Be sure that if you are planning to skip the encryption step below that you upload your backup to an account with a secure password that only you know!

Restore Firefox Profile Backup

Want to restore the backup of your Firefox profile? To start, delete the original ~/.mozilla folder. This will prevent file conflicts and mess ups.

rm -rf ~/.mozilla

Then, extract the archive directly to the home folder, with:

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

Encrypt Firefox Profile Backup

Doing a basic backup of the Firefox profile directory using Tar is quick and easy, but it’s not safe. Anyone that gets their hands on that backup archive can easily extract it themselves and get total access to passwords, history, and everything. That’s why it’s super important to encrypt your backup. On Linux, the easiest (and quickest) way to encrypt a Tar archive is by using GPG encryption.

Note: to use GPG, you’ll need to install GnuPG on your system. Find it via the Gnome Software app, KDE Discover Store and etc.

After creating the backup archive above, go to the terminal and use GPG to encrypt it:

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

Running gpg -c will start the encryption process, and ask you to set a password. Enter a secure and memorable password.

When the process completes, be sure to delete firefox-browser-profile.tar.bz2, as it’s not encrypted. Instead, you’ll need to keep firefox-browser-profile.tar.bz2.gpg as the backup.

Decrypt the file at any time with:

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

Back Up Firefox profile With Deja Dup

Using a Tar archive to backup the Firefox browser profile works in a pinch, but if you want a solution that is easier for the average user, you should consider using the Deja Dup backup tool for Linux. There’s a ton to love when it comes to this app. Here are some reasons you may want to consider using this instead if you find the backup method above too tedious.

  • Supports automatic weekly and daily backup. This can be used to always have a current backup of your Firefox Linux profile.
  • It supports backup directly to external hard drives, SD cards, and USB flash drives, ensuring you’ll be able to quickly take your profile backup with you anywhere even if you are new to Linux.
  • Can backup directly over NFS, Samba, and even FTP/SFTP.
  • Has GPG encryption support to make sure your profile is safe and locked down with no effort.
  • Can restore backups right away, in the correct location easily. Something perfect for new users looking to backup and restore browser settings.
  • Saves the entire /home/user/ directory, rather than just ~/.mozilla, so users will be able to backup all settings, not just the browser.

The traditional method of backing up the Firefox browser profile is easy to do if you’re proficient with the terminal, and don’t mind entering commands here and there. However, if you hate entering terminal commands, and you’re looking for something easy and automatic, Deja Dup is the perfect alternative. Don’t know how to use the Deja Dup backup tool on Linux? Check out our guide here to learn exactly how it works!

If you prefer to use Chrome and want to learn how to back up your Google Chrome Profile, we’ve got you covered.

Leave a comment