Hello, Is there a way to backup the multipass image and move it to another machine ? , I am using multipass on macos m1.
Hi @garichd. Not currently, I am afraid. We’ll start work on snapshots soon, which will be a stepping stone to cloning VMs and, eventually, transferring to a different machine. But it is going to be a while before we can get to that point.
Hello,
is there an update on this request? I will be moving to a new Mac soon and don’t want to go through the pain of setting up my VM from scratch…!
Hi @garichd, we have been making very good progress on snapshots, but we are not just there yet. We are working on a new release with finished features and bug fixes now. Snapshots will hopefully come in the release following that. Cloning VMs is longer term though.
What you could do today is just copy your multipassd directory to the new machine. If the architecture is the same, that should work. It will not work if you are moving from an Intel to an ARM-based Mac (nor would cloned VMs).
wouldn’t the builtin snap snapshot feature of the multipass snap already give you a way to backup/restore your data on a package level ?
Hi @ogra, Multipass is also on Windows and Mac.
Even on Linux, snap snapshots are at a different level. I don’t think they are a good fit (despite the name being the same):
- They are all or nothing (that is, assuming the relevant data directories would be covered, which I am not sure of).
- I imagine they would copy images and thus take a lot more space? (image duplication vs. CoW)
- You would not be able to interrogate those snapshots in a way that is meaningful for VMs (e.g. what state were the VMs on).
Thanks, @ricab, It’s the same architecture ( arm ), I will try the directory method.
yeah, it will only back up SNAP_DATA/SNAP_COMMON (and the respective USER dirs) and indeed it is all or nothing, but if you want to migrate between machines (or do a re-install) it is a suitable way of handling that data … and indeed i didn’t mean MAC or Windows where we do not use snaps
I backup the vault on MacOS as follows, not sure if this is correct though, I am testing the restore part:
> multipass stop --all
> sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist
You have to install gnutar as the tar that comes with MacOS is the BSD tar and it seems to have some sort of issue with links. I am using the multipass version in the backup name for my own purposes:
> sudo su
> gtar -cvpzf /yourbackuplocation/YOUR-HOST-NAME-Multipass-1.12.0+mac-backup.tar.gz /var/root/Library/Application\ Support/multipassd/qemu/vault
To Restore:
> multipass stop --all
> sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist
> sudo gtar -xvpzf /yourbackuplocation/YOUR-HOST-NAME-Multipass-1.12.0+mac-backup.tar.gz -C / --numeric-owner
here is a script that will create straight 1-1 backup of all mulitpass instances, including certs, auth-certs, pems and ssh-key for easy system 1-1 replication. I’ve included 4 variation for you, perhaps one works for your purposes, 2 excludes permission, 2 exclude temp files. 4 resulting folders of ALL of your instances.
To also compress the resulting backup folders into .tar.gz
archives after running the tests, we can modify the script to use the tar
command. This will create .tar.gz
files for each backup folder that is generated.
First create the file to start adding code
Updated Script with Compression
-
Open Terminal and edit the script:
nano ~/test_rsync_variations.sh
-
Add the script content with this updated version:
#!/bin/bash # Define source and destination directories SOURCE_DIR="/var/root/Library/Application Support/multipassd" DEST_BASE=~/Desktop/multipassd_test_backup # Define log file location LOG_FILE=~/Desktop/multipassd_test_backup/test_rsync_backup_log.txt # Create the destination base folder and log file mkdir -p "$DEST_BASE" touch "$LOG_FILE" # Function to run rsync with a specific config and compress the results run_rsync_test() { local FLAGS="$1" local EXCLUDE="$2" local DEST_SUFFIX="$3" local DESC="$4" # Create a destination folder for this test DEST_DIR="$DEST_BASE/multipassd_backup_$DEST_SUFFIX" mkdir -p "$DEST_DIR" # Log what we're doing echo "Running test: $DESC" | tee -a "$LOG_FILE" echo "Destination: $DEST_DIR" | tee -a "$LOG_FILE" # Run rsync and log the output and errors sudo rsync $FLAGS $EXCLUDE "$SOURCE_DIR/" "$DEST_DIR" >> "$LOG_FILE" 2>&1 if [[ $? -eq 0 ]]; then echo "Test $DESC completed successfully." | tee -a "$LOG_FILE" # Compress the resulting folder into a .tar.gz archive TAR_FILE="$DEST_BASE/multipassd_backup_$DEST_SUFFIX.tar.gz" echo "Compressing $DEST_DIR into $TAR_FILE" | tee -a "$LOG_FILE" tar -czvf "$TAR_FILE" -C "$DEST_BASE" "multipassd_backup_$DEST_SUFFIX" >> "$LOG_FILE" 2>&1 echo "Compression of $DEST_DIR completed." | tee -a "$LOG_FILE" else echo "Test $DESC failed. Check the log for details." | tee -a "$LOG_FILE" fi echo "---------------------------------------" | tee -a "$LOG_FILE" } # Test 1: Preserve permissions, include temp files run_rsync_test "-av --progress" "" "preserve_include_temp" "Preserve permissions, include temp files" # Test 2: Preserve permissions, exclude temp files run_rsync_test "-av --progress" "--exclude='*.tmp' --exclude='*.lock' --exclude='*.swp'" "preserve_exclude_temp" "Preserve permissions, exclude temp files" # Test 3: Remove permissions, include temp files run_rsync_test "-rltD --progress --no-perms --no-owner" "" "remove_include_temp" "Remove permissions, include temp files" # Test 4: Remove permissions, exclude temp files run_rsync_test "-rltD --progress --no-perms --no-owner" "--exclude='*.tmp' --exclude='*.lock' --exclude='*.swp'" "remove_exclude_temp" "Remove permissions, exclude temp files" echo "All tests completed. Check the log at $LOG_FILE for details."
-
Save and exit the script by pressing
Ctrl + X
, thenY
, andEnter
.
Explanation of the Script Changes:
- After each rsync operation, the script compresses the resulting backup folder into a
.tar.gz
file using thetar
command. TAR_FILE="$DEST_BASE/multipassd_backup_$DEST_SUFFIX.tar.gz"
: This defines the name of the.tar.gz
archive for each backup test.tar -czvf
: This command compresses the folder into the specified archive.- Both the rsync operation and the compression results are logged to the same log file.
To Run the Script:
Run the script with the same command as before:
./test_rsync_variations.sh
Results:
- The backup folders will be stored in
~/Desktop/multipassd_test_backup/
. - The
.tar.gz
compressed versions of each folder will be stored alongside the original folders. - The entire process will be logged in
test_rsync_backup_log.txt
on your desktop.
What You Will See in the Log:
The log will now include both the rsync operation output and the compression steps. Here’s an example of what it might look like:
Running test: Preserve permissions, include temp files
Destination: /Users/yourusername/Desktop/multipassd_test_backup/multipassd_backup_preserve_include_temp
sending incremental file list
multipassd/file1.txt
12345 100% 3.21MB/s 0:00:01 (xfr#1, to-chk=9/10)
...
Test Preserve permissions, include temp files completed successfully.
Compressing /Users/yourusername/Desktop/multipassd_test_backup/multipassd_backup_preserve_include_temp into /Users/yourusername/Desktop/multipassd_test_backup/multipassd_backup_preserve_include_temp.tar.gz
multipassd_backup_preserve_include_temp/
multipassd_backup_preserve_include_temp/file1.txt
...
Compression completed successfully.
---------------------------------------
Let me know if everything works as expected or if you need any further changes!