SnapD deleted all of my data

How to recover the data "accidentally" deleted by a snap command? Just look inside /var/lib/snapd/snapshots/.

Now onto the long version of the same answer.

One a bright summer day I needed to do a quick test of something. I just needed to uninstall Firefox for it. Only temporary.

I already new that sudo apt remove firefox won't work, because Firefox is a snap application in 22.04. So I did a quick sudo snap remove firefox and watched snapd clear up all the data.

The test succeeded and I wanted to check something in my user profile before installing the deb-packaged Firefox and then it hit me. The profile was gone.

Snaps to do not keep the user's home data in the user's home folder. Because that would've been weird, right? And all of the data was gone. The command above deleted all of my profile without any warning.

I installed the Firefox from Mozilla's PPA and surely it was a clean install, as if I have never used Firefox on this PC at all.

After just a bit of despair, I decided to check the snapshots. The snapshots are stored inside /var/lib/snapd/snapshots/. A directory a normal user can not even browse. Because... reasons? But a sudo su helps. And here it is, a promising looking 1Gb of data in, which contains a few files, including a lex.tgz, which in turn contains a few folders, and finally there a familiar path .mozilla/firefox with the profiles.ini and all the other files. So, simply copying it over into its proper location is the way to restore the "deleted" profile.

Fun fact. If you force-shutdown the PC during the snap remove operation, it gets stuck in a half-removed state. And any attempt to do something with it will result in

$ sudo snap remove firefox
error: snap "firefox" has "remove-snap" change in progress

To get out of this state, you need snap changes and then sudo snap abort 67 and a lot of patience.

To summarize everything listed above, I could finally state that I have plenty of reasons to not like the SnapD at all. I have tried it. I will steer as far away from it going forward as I can.

Posted On


Tags: / /