How to migrate from 0.57@18.04 to 06@22.04

Hello, is there a proper step-by-step how to migrate my mailinabox insance from the last version 0.57 on a 18.04 system to the new 0.60 on a 22.04.

I was reading this old thread about setting up a new instance and just “putting the backup in” - but I have no idea how to do this. Ubuntu Migration Plan - #17 by Eliter

Is there anybody who can help me out with some hints?
It is important to me, that I can keep my current configuration (of DNS, Mailboxes, Users) as well as the data.

1 Like

Generally speaking this will largely depend on what VPS you have.

Prerequisite - ensure your on v0.51 of MiaB or later.

Step 1) Create a new virtual machine (droplet, VPS, compute ec2, etc) during that installation select ubuntu 22.04 as the operating system. DO NOT DELETE YOUR OLD SERVER

Step 2) get your /home/user-data/ folder over to the new server, how ever which way you want to do this (duplicity backup/restore, tar -czvf user-data.tar.gz /home/user-data/ then moving that file via SCP and restoring with tar -xvf user-data.tar.gz, rsync, etc, etc…

Step 3) install mail-in-a-box ( curl -s https://mailinabox.email/setup.sh | sudo bash ) command

Step 4) reconfigure your IP address to be that of the existing server you had previously. This is probably going to different for every service out there so you might have to google how to do this with whatever VPS cloud hosting company your using.

That’s basically it…

1 Like

Thank you for your fast reply.

I am specifically interested in the Step 2
When doing so. (e.g. get all files down to my pc from my instance and the re-upload them to the new instance via SCP) that would include all necessary files/configurations/information such as users, emails, dns records? Or do I need something else? I was reading of adding the backups or so.

For Step 4) that would mean, that I need to change for every domain I have the IP address at the different hosters. I guess thats doable for me :wink:

HOLD ON FOLKS@cmasterdelphi @stylnchris

I think that the steps are a bit out of order and a major step is missing here. I really really recommend following the official guide for moving your box:

However there are some additional steps to take here since our goal is slightly different than what is presented in that guide.

WE WANT TO PRESERVE OUR IP ADDRESS

So in the end we will not be updating Glue records but instead want to make a snapshot of our droplet (using Digital Ocean terms) and then restore that to the original droplet to preserve our IP address…

Don’t do this. You should create a backup within MIaB and then restore it to the new vps.

If you are actually preserving your IP address this is not necessary at all.

I did mention the duplicity backup and restore method in Step 2.

Personally I find it to be very clunky and would much rather use tar or rsync.

Thank you for that link.
I will try to follow through.

Sadly, I am using exoscale and whenever I create a new instance, I will receive a new IP as well.

Is it not possible to simply do sudo apt dist-upgrade on the existing 18.04 box?

ABSOLUTELY NOT possible.

1 Like

Most VPS providers allow you to reinstall the OS. Does Exoscale not?

Hey alento - you stated previously

DO NOT DELETE YOUR OLD SERVER

But if I’m reinstalling my OS, that’s just basicly… deleting my old server right? or am I missing some important detail here. So I think I’m in the same boat here with the new IP. Guess I’ll just contact support there first, to see if maybe they can transfer the IP address at some point.

It is all in the context. But note that was not my comment. That poster was suggesting to rsync the /home/user-data/ directory as an alternative to restoring the backup. I agree that is an easier method to proceed - IF you have a good knowledge of what you are doing and using rsync.

Digital Ocean is the default provider suggested by this project originally, so my answers tend to fall within the parameters of using Digital Ocean.

Digital Ocean offers the ability to create snapshots and to restore those snapshots to a different VM within the same data center. So this advice is applicable if moving within the DO infrastructure.

Spin up a new droplet installing Ubuntu 22.04

Install MiaB

rsync your data backup from the original droplet to some directory out of the way on the new droplet. (Alternatively, as the comment you’re referring to was suggesting, use rsync to move your data - note this is for experienced users only!)

Restore your backup.

Once confirmed that all is good, make a snapshot of the new droplet.

Then reinstall your old droplet with the snapshot from the new droplet.

Run sudo mailinabox from the command line to insure that all settings are correct.

Now you have migrated to Ubuntu 22 while retaining your original IP address.

1 Like

Sadly no. They are quite a bad provider when it comes to features/functionality (or price) - I only use them, cause I had lots of coupons. Eventually when they run out, I will migrate to some other service, but till then, I will be using them, even if its more effort.

I mean, they offer a re-install but not putting snapshots from one instance to another. Snapshots can only be restored to the same instance, which is useless most of the time, only for complete recovery usefull)

Then unfortunately you’ll have to take the path that is more effort. :frowning:

You’ll need to copy/download your backups (don’t forget the secret key!) to another vps or your PC, reinstall Ubuntu 22 and MiaB, then upload the backup and restore it. This path leads to more room for error, but it is the methodology used before restoring snapshots to a new droplet was a thing with DO.

Hi Alento,

If I create a new droplet on DO for the procedure you describe, how should I setup MAIB before saving it as a snapshot? Should I use the name I use on my current box? Or can I use a different name and change it when I restore my backups?

This is the procedure I followed when I migrated from 14.04 to 18.04. (Note: I have my backups on a separate volume that is attached to my droplet).

  1. make final backup after disabling the ports to prevent incoming traffic
  2. detach volume from droplets
  3. reinstall new OS on droplet
  4. install MIAB
  5. reattach volume to droplet and fix links
  6. restore backups
  7. run sudo mailinabox

This worked very well but the advantage of your procedure is that you can wait with the final backup until the last minute, and have less downtime.

You need to install Ubuntu 22 from scratch. An update from 18 to 20 to 22 won’t do it. You get MIAB install errors like I did.

I did this:

  1. Backup /home/user-data on some other machine,
  2. Install Ubuntu 22 on your server,
  3. Restore /home/user-data from the old install,
  4. Run the MIAB installer, which will use your old configuration.

It’s not complicated, but I wasted a lot of time trying the upgrade path, which was a dead end.

So I tried this guide and copied all my backup files to ~/copied
and my scret_key.txt to ~/secret_key.txt

Then I ran from ~ the following commands:
export PASSPHRASE=$(cat secret_key.txt)
mailserver@mailbox:~$ sudo -E duplicity restore --force file:///home/mailserver/copied/ /home/user-data/

and got following:

Synchronizing remote metadata to local cache…
Copying duplicity-full-signatures.somethingblablabla.sigtar.gpg to local cache.
GPGError: GPG Failed, see log below:
===== Begin GnuPG log =====
gpg: AES256.CFB encrypted data
gpg: encrypted with 1 passphrase
gpg: decryption failed: Bad session key
===== End GnuPG log =====

Could it be something with the GPG Versions?
Original:
mailserver@mailbox:~$ gpg --version
gpg (GnuPG) 2.2.4
libgcrypt 1.8.1

New:
mailserver@mailbox:~$ gpg --version
gpg: WARNING: unsafe ownership on homedir ‘/home/mailserver/.gnupg’
gpg (GnuPG) 2.2.27
libgcrypt 1.9.4

You need to include the full path.

i.e. export PASSPHRASE=$(cat ~/secret_key.txt)

I am trusting that the rest of your syntax is correct…

Double checking - will it be enough to do rsync -rlptgoD on the /home/user-data directory? My Nextcloud uses too much space and I don’t have enough space to generate the usual duplicity backup

Are you moving to a VPS with more storage?