4

I frequently roll-back my virtual machines to previous snapshots.
I do not have problems with deb/APT mirrors, since I simply mount local package cache folder with SSHFS from host system.

But recently I have installed snapd to my VM. So now I'm able to install snaps to the currently running VM.

How should I create local cache or mirror for downloaded snaps to reuse them next time?
I do not want to get big snaps from net and want to save my network bandwidth, time and traffic.

7

2 Answers 2

2
+50

Snaps are stored in /var/lib/snapd/snaps/. It should be sufficient to backup this folder.

If a system is rolled back, just copy the desired snaps to /var/lib/snapd/snaps/ and install the snap then, snapd will check if the snap already exists in the folder and doesn't need to download the snap again.

Remind that a snap may depend on other snaps, so maybe it's the best to restore the whole folder.


The reproducible way is below:

  1. Install some snap to save it for reuse:

    snap install hello-world
    cd /var/lib/snapd/snaps
    sudo chown $USER: *.snap
    cp *.snap /some/place
    
  2. Reuse the snap from cache

    cd /some/place
    snap install --dangerous ./core_6405.snap
    snap install --dangerous ./hello-world_27.snap 
    
1
  • Thanks, I added tested reproducible way to your answer to make it more useful for future readers :)
    – N0rbert
    Mar 1, 2019 at 18:00
0

You may mount a Snap server as a web server, light instructions here (original here).

You must log in to answer this question.

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