6

I am running Firefox on Ubuntu 22.04.

When I installed Ubuntu 22.04, I copied a pre-existing home folder from an Ubuntu 20.04 installation. This included ~/.mozilla/firefox/ and the Firefox profiles it contained from the 20.04 system.

A major difference between Firefox between Ubuntu 20.04 and 22.04 is that on the old 20.04 system, Firefox was a normal executable located at /usr/bin/firefox, while on 22.04, Firefox is by default a Snap at /usr/snap/firefox. Evidently, the Snap includes its own data, including profile data, at ~/snap/firefox/.mozilla/, which did not intially exist when I copied the home folder. Nonetheless, when I opened Firefox (using the Snap executable), the browser immediately found my profile data in ~/.mozilla/firefox/, and the transition between the 20.04 and the 22.04 system was largely seamless.

Today, I decided to replace the Snap version of Firefox with the Mozilla PPA version, as described in this AskUbuntu post. On advice from a separate guide, I first checked for profile data for the Snap version in ~/snap/firefox/.mozilla/. In fact, I found that I didn't even have that directory:

~/snap$ ls -a firefox/
total 20K
drwxr-xr-x 5 user user 4.0K Nov  4 09:22 .
drwx------ 8 user user 4.0K Aug  4 20:32 ..
drwxr-xr-x 4 user user 4.0K Nov  1 22:05 2047
drwxr-xr-x 4 user user 4.0K Nov  4 09:22 2058
drwxr-xr-x 4 user user 4.0K Aug  4 20:03 common
lrwxrwxrwx 1 user user    4 Nov  4 09:22 current -> 2058

That made sense, since obviously Firefox was using my profile data in ~/.mozilla/firefox/ instead.

To clarify the state of the matter at this point:

After making every reasonable effort to research the subject, I had zero reason to believe that any of my Firefox profile data was in the Snap directory ~/snap/firefox/.mozilla/, and every reason to believe that all of my Firefox profile data was in the normal location, ~/.mozilla/firefox/.

So, I uninstalled the Snap and installed the Mozilla PPA version of Firefox as described in the post I linked earlier.

After restarting Firefox, I find that my profile has been reset to its state when I first moved it from the Ubuntu 20.04 system to the 22.04 system. All of my tabs, all of my work, literally everything for the past four months is gone. Presumably, the Snap version of Firefox found my profile info in ~/.mozilla/firefox/, loaded it, but then kept further data in its own secret location within ~/snap/firefox/ without telling me. Furthermore, it must have deleted this data when I removed the Snap, which if true would defeat the entire purpose of keeping separate profile data for an application.

This is all that's left in ~/snap/firefox/.mozilla/:

~/snap/firefox$ ls
total 0
lrwxrwxrwx 1 user user 4 Nov  4 09:22 current -> 2058

It's a symlink that points to nothing.

Is there any way at all to recover my Firefox profile data from the past four months that it was operating under the Snap version?

1 Answer 1

7

Seems you were looking for your firefox-profile in the wrong location, you looked in ~/snap/firefox/ for the .mozilla-folder but you should have looked in ~/snap/firefox/common/. Please see this answer for reference.

Switching to the snap version of firefox should have copied your old firefox-profile from ~/.mozilla/firefox to ~/snap/firefox/common/.mozilla/firefox. You will be still able to examine your snaps user data even if the snap is removed now.

When you remove a snap, all user data will be removed but a snapshot of the user data will be saved. Important to know is the fact that the snapshot will be kept for only 31 days.

Only if you remove a snap with the --purge-option like in snap remove --purge firefox, all userdata will be lost, no snapshot is created.

You will find the snapshot as a zip-archive in /var/lib/snapd/snapshots/. Since this folder is locked you will need root-privileges to find the snapshot, copy it to your home-directory and take ownership. The following example uses the wire-snap, I don't have the firefox-snap installed in my system:

~$ sudo ls /var/lib/snapd/snapshots 
[sudo] password for mook: 
5_wire_3.24.2939_237.zip
~$ sudo cp /var/lib/snapd/snapshots/5_wire_3.24.2939_237.zip ~/
~$ sudo chown $USER: 5_wire_3.24.2939_237.zip

Now you can use your graphical archive-manager to open and browse the snapshot and hopefully extract your lost firefox-profile from it.

1
  • 3
    Spot on, thank you so much. A little more detail if it helps someone else: Once unzipped, the archive will contain a sub-archive user/{username}.tgz, where {username} is your Ubuntu login. Once this archive is unzipped ($ tar -xf {username}.tgz), it will unpack a folder user/common/.mozilla/firefox/ that contains Firefox profile folders in the standard format; i.e. xxxxxxxx.default/. After backing up the corresponding profile folders in ~/.mozilla/firefox/, you can copy the archived folders into ~/.mozilla/firefox/ in the normal way of restoring Firefox profile backups. Nov 6, 2022 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .