Missing $SNAP_USER_DATA data on upgrade

Howdy Gang,

One of my snaps had an update last month and with it came 2 separate reports of data loss. The snap in question doesn’t do anything out of the ordinary, there’s no hooks that configure the application (aside from the default install hook for fonts made by the Gnome extension), and there’s been no similar reports in any other release of the application. To add on to this, the snap forces a minimum version of snapd that has Refresh App Awareness enabled, and both reports happened within 2 weeks of the snap being pushed, which would suggest the app was almost certainly not running at the time.

The impression I would have is that the usual upgrade mechanism failed to copy the entireity of the $SNAP_USER_DATA folder for some unknown reason. The log files for the application were reset after the upgrade, which are usually append only, and alongside it, the rest of the application data appeared to also be missing.

I though it’s best to raise awareness here, to see if any core snapd devs would be able to offer input in how to diagnose potential root cause, and importantly, see if it’s likely to occur with other snaps/users/etc.

Issue: https://github.com/laurent22/joplin/issues/7489

Is there any advice that can be given for the users in the thread above?


I try to say this every chance I get (because I really hate the naming convention) but looking at https://snapcraft.io/docs/environment-variables, $SNAP_USER_DATA has the revision number in it which means that data stored there is lost on update. $SNAP_USER_COMMON does not have the revision number in it so I think that data will persist across updates.

(hopefully I’m wrong but I get the feeling this is how it works)

Not true, all content is copied to the new versioned dir during upgrade, so that rolling back with snap revert... will give you a matching config, even if the app changed its format… you should always use that dir for your configuration files to make sure they are applying to the correct app revision…

Since the content of the data dir is copied, you should use the common dir for things like caches and persistent storage of data that does not need to be tied to a specific app version, that will speed up the update process (and indeed save disk space)

1 Like