Upgrading Mailinabox to Version 60 and higher

Important: If you migrated your nextcloud db to mysql or another relational database you’ll need additional steps to get nextcloud back running.

Doing an Upgrade to 60+ will require also upgrading the underlying Ubuntu to 22.04.

This can only be done by

  1. Upgrading your Mailinabox to the latest Version for Ubuntu 18.04
  2. Setting up a new Mailinabox server with Ubuntu 22.04
  3. Migrating the old mailinabox to the new server

Step 1: Upgrading your Mailinabox to 57a

Although in the release notes of Mailinabox version 60 they only mention an upgrade to 51+ as a prerequisite, Nextcloud will not work, unless you’ve upgraded to 57a before doing the migration.

Luckily this is really easy. Just connect to your current (old) server and simply run the (normal) upgrade command

curl -s https://mailinabox.email/setup.sh | sudo bash

It will automatically detect that you’re still running Ubuntu 18.04 and only upgrade to the newest mailinabox version for that Ubuntu.

Step 2: Setting up a new Mailinabox

Create a new VPS at your provider with Ubuntu 22.04. When done, set up a clean, new Mailinabox instance by logging in and executing

installing different version: https://discourse.mailinabox.email/t/how-to-install-older-version/2742

export TAG="v61.1"
sudo --preserve-env curl -s https://mailinabox.email/setup.sh | sudo -E bash

This will install v61.1 of mailinabox. Installing the latest version did not work for me.

Once that is done, you can start the migration.

Step 3: Migrating Mailinabox to a new server

3.1 Disable connections to the old box

Details: https://mailinabox.email/maintenance.html#upgrade

In order to migrate your mailinabox to a new server, you first need to block all traffic to your old box (so you don’t accept any mails or other changes with the old machine that the new machine anymore).

sudo ufw reset
sudo ufw allow 22 # enable SSH access so you don't lock yourself out
sudo ufw enable

3.2. Create and copy a backup

On the old box, create a backup

cd ~/mailinabox
sudo management/backup.py

You then copy the encryption key to your new machine

scp /home/user-data/backup/secret_key.txt root@[IP OF NEW MACHINE]:/root

And then you copy the backup to the new machine

scp -r /home/user-data/backup root@[IP OF NEW MACHINE]:/root/

When completed the files will be at /root/backup/encrypted on the new machine.

3.3. Restore backup on the new machine

Log in to your new machine. Before restoring the backup, you need to delete the self-generated SSL certificate (otherwise you will run into errors when restoring)

 sudo rm -rf /home/user-data/ssl/* 

Now you can restore from the previously copied backup

export PASSPHRASE=$(cat /root/secret_key.txt)
sudo -E duplicity restore --force file:///root/backup/encrypted/ /home/user-data/

To restore your backups, just run

sudo mailinabox

Now you only have to adapt the DNS konfiguration as per the Status page on /admin/ frontend.