How to import&restore snaps from a backup?

before erasing old SSD, I did a “snap save” (Ubuntu 21.10) Then I backed up the .zip files produced in /var/lib/snapd/snapshots/

Now, on the new system (Ubuntu21.10) -I tried a restore by importing first:

$ snap import-snapshot /media/andre/62GB/7_anbox_4-56c25f1_186.zip
error: cannot import snapshot 4: cannot read snapshot import: archive/tar:
       invalid tar header

What is the correct procedure to restore snapshots on a fresh-installed system?

This appears to ba snapshot taken directly from /var/lib/snapd/snapshots rather than an exported one. Did you use snap export-snapshot?

Anyways, I think you can try to put the zip file under /var/lib/snapd/snapshots, then restart snapd and run snap saved to check whether it is listed there, and run snap check-snapshot <id> to have it checked. If that works, you can then install anbox and run snap restore <id>.

FWIW, I think the docs page about snapshots https://snapcraft.io/docs/snapshots is incomplete and does not mention export-snapshot/import-snapshot commands. (cc @degville)

Thanks for letting me know, and you’re right about it being incomplete! I’ll make sure those commands are added today.

@mborzecki - thank you . I moved the files back as you suggested, did “snap saved” which worked, then “snap check-snapshot 7” - which worked fine too, - and finally “snap restore 7” - which seems to have worked too. (it took some time, no error)

However - now I restored the snaps, but the GUI still does not have any shortcut to anbox or other restored apps.

@degville - thanks for fixing it, I was pretty happy having found “save” and thought it was kind of odd no path to “where it is saved” was given, I completely missed the “export-snapshot” feature - and got scared that the snapshot I have may be incomplete (which I still think they may be in terms of missing .desktop files or links that launch them.)

Maybe I should install the apps, THEN do a “snap restore” ? - please advise.

snapshots just keep track of your data, you still need to install the snap.

thank you - I reinstalled anbox, restored , and it won’t start. (maybe old config, maybe something else.) how can I start fresh with the anbox snap ? (how to delete any settings/configuration applied by restore, and start anbox snap just as it never was executed on this computer?)

Snap’s data is stored under $HOME/snap/<snap-name> and /var/snap/<snap-name>.