5

I assume there's a way (but maybe not?) to import/export a vms from multipass. For the life of me I can't find documentation on this. Basically, I'm planning to do a clean install of 19.10 and I would like to backup a couple of my vms in multipass to carry them over. Any ideas?

Ryan J. Yoder
  • 918
  • 8
  • 16

3 Answers3

7

We currently have no "easy" way to export and import Multipass instances. But it's just data, so it should be possible to manually do it:)

If you'd like everything back to the way it was, I would just save the whole of /var/snap/multipass/common/data/multipassd/ and after doing the clean 19.10 install and installing the Multipass snap, just copy that back to the same location and do a snap restart multipass for the daemon to pick up the changes.

If you want to pick and choose, that'll be a bit more difficult as you'd need to selectively pick the instances in /var/snap/multipass/common/data/multipassd/vault/instances and then modify both /var/snap/multipass/common/data/multipassd/vault/multipassd-instance-image-records.json and /var/snap/multipass/common/data/multipassd/multipassd-vm-instances.json accordingly.

I hope this helps and good luck!

1

Based on Ryan comment, here is the full process to backup and restore multipass and instances using snap snapshot, this method has only one requirement: the server that restores the snapshot must have the same username as the server that generated the snapshot.

stop all instances to generate the backup

multipass stop --all

generate a snapshot of multipass snap

sudo snap save multipass
# Set  Snap       Age    Version  Rev    Size    Notes
# 3    multipass  1m33s  1.12.1   10053  2.05GB  

export the multipass snapshot as .zip

sudo snap export-snapshot <set> <filename>.zip
# sudo snap export-snapshot 3 multipass-snapshot.zip
# Exported snapshot #3 into "multipass-snapshot.zip"

transfer the multipass-snapshot.zip from the old to the new server

# using scp or an alternative

import the multipass snapshot in the new server

sudo snap import-snapshot multipass-snapshot.zip
# Imported snapshot as #1
# Set  Snap       Age    Version  Rev    Size    Notes
# 1    multipass  8m53s  1.12.1   10053  2.05GB  -

restore

sudo snap restore 1
# Restored snapshot #1.

check

multipass list
# Name                    State             IPv4             Image
# deserving-hornet        Stopped           --               Ubuntu 22.04 LTS
# titillated-pinniped     Stopped           --               Ubuntu 22.04 LTS
0

Good solution with snapshot. I don't know if I'm right, but multipass VMs are not intended to clone or export as Virtualbox images, as they were created to run in the cloud, not in Desktops. The correct way to have similar images is through the cloud-init system and YAML cloud-config files, which allows, through a file passed when creating the machine, what must be installed programs and the replicated configurations.