I’m setting up a backup of my laptop using Pika Backup. Pika Backup already handily has some options that you can set to exclude some directories from your backup, as you can see in this screenshot:
It would be good if I could only backup my personal data and configuration from my Snap installations, and not the Snap applications themselves. The Snap applications can be very large (multiple GBs), and I don’t need them in my backups taking up space. I can always reinstall them using snap commands.
Which directories can I configure my backup tool to exclude?
Here is my guess: I can exclude ~/snap/*/*/.cache . Anything else that I can exclude?
As an aside, I wish Snap would respect the XDG Base Directory specification. All the cache directories should be under ~/.cache/. Even creating a symlink from ~/snap/firefox/common/.cache to ~/.cache/snap/firefox/.cache would be a start. A lot of backup programs already know to exclude ~/.cache.
As a further aside, I wish the snap didn’t put an ugly snap directory in my home directory. Please finally fix bug #1575053. It’s been nine years.
everything underneath this dir is actually application user data, while excluding the browser cache makes surely sense, I’d not exclude anything else from there …
snap packages themselves live under /var/lib/snapd/snaps and get loop-mounted into /snap, you definitely want to exclude the latter one or even both …
Thank you for your answer, that’s good to know. Thank you also for your tireless efforts in these open source projects. We all benefit from it.
I have a follow-up question. If I look under ~/snap/firefox, I can see the directories 5561, 5600, common and a symlink current. I presume the numbers 5561 and 5600 are version numbers of the Firefox snap (visible in the output of snap info firefox). Why would they have separate user data? Shouldn’t the user data remain the same?
I’ve also noticed that common/ has the majority of the data by total file size:
It would seem that only common/ needs to be backed up. If the data in 5561/ and 5600/ gets discarded after a couple of upgrades, it would seem that I don’t need a backup of it.
The versioned dirs are actually tied to the respective firefox revision as you already noticed … typically they would be used to carry your config of the app, so in case config options change between revisions you will get the config data matching the revision you run when i.e. doing a snap revert… during upgrades the data in these dirs is copied forward to the next version and the current symlink is changed to point to the currently running one …
So if you want to access that data you should use the current symlink to be sure you access the data of the actually running variant
The common dir is not versioned and usually carries payload data that does not necessarily need to match any versions (databases, caches etc) … firefox specifically does not really make use of these features though and simply dumps everything into the common folder
snapd could be easily broken and requires apt reinstall snapd when snapd-repair and snapd-failure services are not so eagerly ready and when that occurs, snaps needed to be reinstalled(or maybe systemctl restart …, not snap start --enable some_service)… and seems that such problems are not so rare…
so ~/snap could be user data, but snap list with installed snaps missing… and in ~/snap are also cached data with uninstalled snaps…