The upgrade from Mailinabox v57a and Ubuntu 18.04 to Mailinabox v60 and Ubuntu 22.04 LTS is one that needs to be done from scratch. According to the developers, upgrading an existing installation isn’t supported. Here, we’ll be deploying a new MIAB installation with v60 and Ubuntu 22.04 LTS while restoring a backup from v57a.
First, install a fresh copy of Ubuntu 22.04 LTS Server.
Next, upgrade it to the latest packages:
# sudo apt update && sudo apt upgrade -y
Next, let’s install MIAB with the provided script:
# curl -s https://mailinabox.email/setup.sh | sudo bash
Follow all the instructions and answer any questions with the same responses you gave on your old box.
We’ll grab our old backup from Backblaze with the b2-linux tool from https://github.com/Backblaze/B2_Command_Line_Tool/releases/latest/download/b2-linux
# wget https://github.com/Backblaze/B2_Command_Line_Tool/releases/latest/download/b2-linux
# chmod +x ./b2-linux
Let’s grab our backup from Backblaze:
# ./b2-linux authorize-account <applicationKeyId> <applicationKey>
# mkdir ~/backup/
# ./b2-linux sync b2://bucketname/* ~/backup/
Let’s restore our encryption key from the old installation. It’s located at /home/user-data/backup/secret_key.txt on your old box. Put that in the same location on your new box. I just SSH’d into my old box and:
# sudo cat /home/user-data/backup/secret_key.txt
Then I used nano to paste it into my new box:
# sudo nano /home/user-data/backup/secret_key.txt
Finally, we’ll use duplicity to restore and decrypt the data. Be sure to replace [replace with your user] with your actual username for the absolute path to your backup files.
# export PASSPHRASE=$(cat /home/user-data/backup/secret_key.txt)
# sudo -E duplicity restore --force file:///home/[replace with your user]/restore /home/user-data/
At this point, it’s possible that an error 17 has popped up complaining about an existing file. It’s safe to delete this file and re-run the duplicity restore command.
Finally, rerun mailinabox setup to complete the install.
# sudo mailinabox
You’re all set.
For bonus points, it’s possible to strictly use duplicity to pull the backup data from Backblaze as it understands the b2 protocol, but I haven’t put any time into this. Additionally, this guide doesn’t take any networking or changes in DNS necessary for deploying a new box into account, so be sure to reference best practices at https://mailinabox.email/maintenance.html#moving-boxes for more information. As of the date of this writing, it hasn’t been updated for Ubuntu 22.04, but the same basic principals apply.