Automatic snapshots, snap remove --purge proposal

With automatic snapshots feature landed and to be released with 2.39, snapd now creates a snapshot of the snap data and configuration automatically on snap remove and keeps it around for 31 days by default. It has been observed that because of that some snaps are now slow to remove if they create lots of data (one example is multipass snap, with 2GB+ of data).

While the feature can be disabled with snap set core snapshots.automatic.retention=no, it acts as a global flag. Therefore after a short discussion about the issue it has been proposed that remove command grows a new flag that disables automatic snapshot when removing the given snap only, e.g:

snap remove --purge myfatsnap

Any thoughs/suggestions about the new flag are welcome and if there is no disagreement, Iā€™ll implement it soon.

13 Likes

I support having a --purge flag, for exactly the case you described, removing multipass which generates gigabytes of data.

4 Likes

Sounds reasonable to me and I canā€™t think of any downsides to having this flag. The name of the flag seems obvious and a good choice.

Thanks for feddback! The tentative PR is here: https://github.com/snapcore/snapd/pull/6870

Thanks for this, I was just about to ask for just such a thing. The snap remove now takes too long for my tastes due to it creating a snapshot for the data.

One quick comment on this older item. Is this behaviour in the documents? I went searching for this as someone pointed out that a user would never know this behavior by default.

EDIT Found it. In the snapshot portion of the docs. I think itā€™s pretty deep in there for an average user though.

Edit 2 Iā€™m taking a Mulligan on this one. It is in the getting started guide as well

You have a point though, it should probably be documented (or referenced) close to snap remove as well. CC @degville

Thanks for flagging this (cc @bashfulrobot). Itā€™s an option that should definitely be more discoverable. Iā€™ve added it to the Getting started guide, and Iā€™ve also added some hopefully better navigation on that page to help see what information it includes. Iā€™ll add some quick details on snapshots too.

No problem. It just came up as I was having a friendly discussion with a user who tends to be a little negative towards the tech.

I would suggest that things that are critical to a users data may even warrant some visibility within the cli tool --help command. Maybe even under the ā€œremoveā€ button in gnome software.

The reality is, there are users who will not go search out the docs, or maybe even be a new user to Linux who may not realise where to go and look. So putting the data sensitive info into a spot that is maybe a little more intuitive - could be a good thing? ĀÆ_(惄)_/ĀÆ

I know that might be a stretch goal, or require other teams, but I am just spit-balling here.

Incidentally, the cli (snap remove --help) was updated just a few days ago with https://github.com/snapcore/snapd/pull/8782 (will become available with snapd 2.46 I suppose).

1 Like

perfect!

That is the first place I would hope to find it.

Btw, I couldnā€™t remove lxd at all due to this automatic snapshot thing. It tried to do something for several hours and then failed. Iā€™m glad Google took me here and --purge was an acceptable solution to a problem that shouldnā€™t exist.

Right, there are some extreme cases (lxd, multipassā€¦) where it would probably make sense to ask/warn about potentially huge snapshot (not doing automatic snapshots by default because of extreme cases isnā€™t a good idea IMHO; for users wanting that there is always ā€œsnapshots.automatic.retention=noā€ config option mentioned earlier).

FWTW, there are some other improvements in the works such as not attempting an automatic snapshot if disk space is low and doesnā€™t guarantee successful operation.

1 Like

this snapshot feature is a horrible thing, on servers this is ok (probably, but maybe not, what if it contains terrabytes of BLOBs or something) but for common users it is nightmare! I in UI just clicked remove for Steam app and it just hangs forever, tried aborting it - nothing! And about hour or two of my struggle led me here where I learned that when I remove an app it creates backup for it - seriously? - I want it to be removed! just removed! NOT TO CREATE A SNAPSHOT OF ABOUT HALF OF TERRABYTE!!! F*ck That is exactly why Linux has the reputation of being hard! No regard of user experience, I should not figure out all the internals of how things work - I have enough of that when I am at work.

At least a warning would be great.

Agree with soltysss. This is bizarre, unexpected, and unwanted behaviour. Tried to remove the docker snap, and was taking forever. Cancelling and using --purge worked, but probably shouldnā€™t be necessary?

I have never expected removing software to create some kind of snapshot or backup, interested in where the idea came up that this is required? Is it because snaps are possibly (erroneously) saving user data inside the snap, and you donā€™t want to accidentally blast that?

Snaps are saving user data in your homedir and in their dedicated writable directories under /var ā€¦

If you take a look at how Debian packages work, they leave this content untouched if you remove and not purge a package, so of you re-install a package it will find all the old dataā€¦ But this also means your disk will fill up over time if you do not generally purge on removal, so this is not different to any other packaging system out there.

Snaps simply keep a compressed backup of that data around to lower the footprint for that dataā€¦ But the compression comes at a time cost for packages that have rather large amounts of data to compress like i.e. docker or lxd imagesā€¦

You can list all backed up data with the snap saved command and there are multiple other commands around snapshots to deal with them.

Would you rather lose all your data when removing a package ?

so this is not different to any other packaging system out there.

I mean, itā€™s different in that it takes seconds to sudo apt remove a package, and as other users said, potentially hours to sudo snap remove a package, so thereā€™s thatā€¦

Would you rather lose all your data when removing a package ?

I would expect that no user data would ever exist ā€œinsideā€ the snap, and that the entire snap would be destroyed upon a remove command.

Nothing exists inside the snap beyond what has been originally installed, snaps are read-only filesystem images ā€¦ like ISOs, nothing can save anything inside themā€¦

The snapshots only happen for actual user data that was written to the two writable directories under /var that a snap owns or the snap/ directory in your home.