Moving back from Power Mail-in-a-Box to the official version

Hey,

We have been using Power Mail-in-a-Box for some time now because the official version wasn’t supporting Debian. As we upgraded our Infrastructure we are no longer limited to using Debian, and also Power Mail-in-a-Box was abandoned we would like to move back to the official version of MiaB. What would be the best way to do it without losing our emails?

Thanks for your help in advance!

Winux

I can think of a few ways, each with different goals. This is top of mind, you should try it out and see what you encounter on the way. I won´t guarantee this is complete or correct :wink:

If you only care about your mails:

  • Install a new Ubuntu server with the latest MiaB version, but keep your old box around, don´t yet move the DNS entries etc
  • Re-create all mail users (can be done programmatically using the API if there are many users)
  • Use something like imapsync to copy all mails to the new box.
  • Now disable postfix on old box, redo the imapsync step (should be fast because only new mails are transferred)
  • Move DNS to new box
  • Using this method you’re sure that your box is in sync with the official MiaB installation.

Another way:

  • Take a backup of your USERDATA
  • Install a new Ubuntu server with the latest MiaB version, but keep your old box around, don´t yet move the DNS entries etc. Use the recommende way to recover the backup
  • Now see if the box works as intended. There might be issues with the MiaB installation because power MIAB did things differently.
  • Fix the issues
  • If you’re satisfied with the installation, start again from the first step, but now move over the DNS etc as well. Consider the first time round as a dry run to see if it works
  • This way has the potential of costing less effort, however, there might be remains in your backup of the Power MiaB way of working that might hurt you in the future. Notably, there might be issues with the quota system, which might be different between the versions.
    This way also takes into account the stuff you have in nextcloud and other settings.

Perhaps @davness has something to say on the subject.

1 Like

Ive

Taken a backup of your /home/user-data

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) copy your /home/user-data/ folder over to the new server, however 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, winscp, or other methods could be used for moving the file.

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.

I’m pretty sure this will basically put you back to normal.


But essentially all of you mail is under /home/user-data/mail/mailboxes//
So even if this method doesn’t work, copying over the individual mailboxes would also work for restoring the mail in each users mailbox. However you might need to create the mailboxes first and log into each mailbox 1 time via webmail so the folder structure is created. Then the files in “cur” & “new” can be moved into each corresponding folder.

Imapsycn is free under 3GB but you can start all over and finish the move. This is a good way to keep the folder structure and when you move between providers MIAB to Proton, etc.

But the fastest way is to recreate users, aliases, custom dns entries, and then copy the USERDATA.

No need to use the backup method.

The ONLINE version is free for mailboxes under 3gb.

If you install your own on a vps, it is unlimited. Imapsync is in the repo’s.

2 Likes

Hi,
Thanks for your reply! We will try to move the files

How did you make out?

We haven’t moved yet but it will be done in 2 weeks.

We successfully moved back to mainstream by copying the corresponding cur and new folders one by one.

1 Like

A short feedback if others want to migrate back:
I was able to successfully migrate today from the latest PowerMiaB v60.5 under Ubuntu 18.04 LTS to MiaB v71a on Ubuntu 22.04 LTS using these instructions:
https://mailinabox.email/maintenance.html#moving-boxes

All data could be transferred. Only the additional functions that were available in PMiaB could no longer be used afterwards.

The bigger issue is that NextCloud on Power-Mailinabox is 2 major releases behind, so if you have many files, shares and more in there you need to first install the P-MiaB version of NextCloud and then upgrade one version at a time to the current Nextcloud before running mailinabox again.

Pretty sure most of that will self heal a bit no? Your copying over the whole /home/user-data/

Maybe the database for nextcloud will be unhappy with Power but most of the file share stuff was never suppose to be used that way it was only for carddav/caldav

I would try it on a text box first and see how it works

The first rule that users apply is “if it’s there, use it”, which is what gets done with Nextcloud. It’s there after all, there’s even an admin-enable script to help things along. So “never supposed to be used” doesn’t fly in the real world out there :slight_smile:

did you attempt to try and see if it just upgraded successfully? (with a test box)

I would try it but I never had anything on Power. One thing that I’ve learned — the hard way is going to these forked versions seems great, but once they stop being worked on it becomes a huge issue due to vulnerability and keeping up with patches and software updates/os updates. At least according to Mail-in-a-Box - Wikipedia MAIB has been around for 12 years and it still gets worked on. So this seems to be a relatively safe place to be…

I did an fresh install of MIAB and restored the backup. Nextcloud doesn’t work because of the 2 full releases that PMIAB was behind. I have not exhausted all the options yet, but I did try to install the older Nextcloud and upgrade twice to get to the current one. However, this is not that high on my list of priorities, since PMAIB still functions pretty well and the other components are updated with security fixes regularly. I do realise that is has to be done, so I will get around to it. It may in the end be easier to transfer the files out of Nextcloud, do the new install, restore the mailboxes et al, and then simply upload the files to Nextcloud again.

I believe you can just copy the files in (on the backend via Linux) after you upgrade like your thinking then run commands to scan them all at once see the page above.

Keep in mind any folders that were shared etc will have to be setup again.

That is good to know, thank you!

I have found this:

  1. Install latest MIAB in a new VM
  2. Restore the backup from P-MIAB
  3. wget https://download.nextcloud.com/server/releases/nextcloud-24.0.12.tar.bz2
  4. extract it
  5. tar -xjf nextcloud-24.0.12.tar.bz2 -C /usr/local/lib/
  6. mv /usr/local/lib/nextcloud /usr/local/lib/owncloud
  7. chown -R www-data:www-data /usr/local/lib/owncloud
  8. chmod -R 750 /usr/local/lib/owncloud

Now run “mailinabox” and it will see Nextcloud is old and upgrade it, one major version at a time.

Done!

I first tried manually upgrading Nextcloud, but got stuck on all sorts of issues, so I wanted to check what the status of all the components is by running “mailinabox” and to my surprise it took care of it all.

I suppose it would be possible to upgrade Ubuntu to 24.04, re-install mailinabox and do an upgrade too. I’ll test that next.

So I tried the “upgrade” path this afternoon.

… the script installs all the components and upgrades Nextcloud to v25 and then v26.

However, python balks at this point:

Installing Mail-in-a-Box system management daemon...

FAILED: /usr/local/lib/mailinabox/env/bin/pip install --upgrade pip
-----------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/mailinabox/env/bin/pip", line 5, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
-----------------------------------------

I haven’t been able to figure out how to get past this. Any help would be appreciated, since it seems the rest is working.

Looks like the Python environment was not created (properly)

First move the old environment away (if it’s there, so you have a backup)

sudo mv /usr/local/lib/mailinabox/env /usr/local/lib/mailinabox/env_old

Now the setup will probably run. If not, use the following to create a new Python environment

sudo su
export DEB_PYTHON_INSTALL_LAYOUT=‘deb’
virtualenv -ppython3 /usr/local/lib/mailinabox/env

1 Like