Red/VPS/Migración Mailinabox

De Portfolio Academico
< Red‎ | VPS

This is a simplified made exclusively for my case. PLEASE DO NOT ATTEMPT TO APPLY IT AS-IS. CHECK OFFICIAL MANUAL IN THIS LINK.

Let your users know what’s happening

Your box is likely to be off-line for some time during the upgrade process. If you change IP addresses, DNS may take a few days to update. Let your users know ahead of time what your plan is.

Update your existing box to the latest version of Mail-in-a-Box for Ubuntu 14.04

My box is already up-to-date.

Perform a final backup

Stop mail services

You will be performing a backup + restore to move your data to the new box. To ensure you have a final backup, first block access to your box to all services besides SSH so that no new emails are sent or received, no calendar or contacts data is changed, and so on, after the backup completes — you don’t want to have any data on the box that isn’t backed up.

Log into your box using SSH and run the following commands to change the software firewall rules to block everything except SSH:

ufw reset
ufw allow 22
ufw enable

Make a backup

Then perform a backup to ensure you have everything backed up since the last nightly backup run. Run:

cd mailinabox
management/backup.py

Copy the backups and the encryption key used to encrypt the backups off of your box and onto your desktop or somewhere else.

Using any SFTP program like FileZilla (or scp if you know how) copy your backups from /home/user-data/backup/encrypted and the encryption key at /home/user-data/backup/secret_key.txt on your box to somewhere safe.

Create a new Ubuntu 18.04 machine for your new Mail-in-a-Box

Done.

Restore your backup

Still logged into your new machine, you will now restore your backup.

First, move aside the new machine’s empty Mail-in-a-Box user-data directory.

mv /home/user-data /tmp/user-data.empty

Using any SFTP program like FileZilla (or scp if you know how) copy your backups from wherever you stored them to somewhere on your new machine.

Then restore the files:

export PASSPHRASE=$(cat /path/to/secret_key.txt)
duplicity restore --force file:///path/to/backup /home/user-data/

Re-run Mail-in-a-Box setup

Your files are back in place, but you must re-run Mail-in-a-Box setup one more time to set up all of your domains and other settings.

Run:

mailinabox

After that, your new box should be operating correctly.

Updating DNS

If your IP address changed, you’ll need to update DNS. If you were using your Mail-in-a-Box for DNS (the recommended way), you’ll need to go to your domain name registrar and update the “glue records” that you created during setup. (If you are serving mail for more than one domain, glue records only exist for your box’s primary hostname — you do not need to make any changes for other domains.)

If you are using external DNS, compare the External DNS page of the Mail-in-a-Box control panel at /admin on the new box to your DNS settings.

Wrapping up

Log into your new box at /admin and look over the system status checks. If your IP address changed, you’ll have a lot of errors — but some might be fixed automatically once DNS changes update, which can take hours or a few days. Look over the final steps in the setup guide for additional tips.

Test your new system: send/get emails, look at the calendar, admin section, etc. Look at some of the test services listed at the end of the setup guide.

Once everything is working

After you’re sure everything is working — maybe a month later — go back and delete your old machine (unless you used Digital Ocean’s Rebuild feature). You may want to test that you are able to do anther backup + restore to a third machine to make sure you have that process down, in case you need it again.