1 8.2 Restore install mailcow
Asif Bacchus edited this page 2021-02-10 07:48:19 -07:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Restoring Backups - install mailcow

We need to do a basic vanilla installation of mailcow so that we have something to restore data into. Follow the official mailcow documentation but do not start mailcow yet!

N.B. DO NOT start mailcow via docker-compose up -d just yet! We need to do some stuff before. You can, however, feel free to pull the containers.

Remember to run generate_config.sh so that snake-oil certificates and the CA file is created. This is important regardless of whether or not you are using your own certificates. Since we will be using our old mailcow.conf, it doesnt really matter what options you choose when running the generate script.

Copy old configuration

Before we start mailcow, we need to copy our old configuration files so that everything is created using the correct project name, hostname, etc. This is simple since we have our backup already extracted.

mailcow.conf

When you ran generate_config.sh a mailcow.conf file was created. Since we dont need that file, you can delete it. Next, well copy our old configuration from our backup:

cd /opt/mailcow-dockerized
rm mailcow.conf
cp /var/mcRestore/opt/mailcow-dockerized/mailcow.conf ./

Customizations and certificates

If you have any custom postfix/unbound settings, certificates and docker-compose overrides, we need to copy those so that the environment is consistent with our backup. Ill provide a few examples here, but ultimately only you know your own particular setup. Alternatively, if you have no idea what Im talking about, you can likely skip this section entirely 😜

# assuming you are in the mailcow home directory (e.g. /opt/mailcow-dockerized)

# copy certificates
mkdir /certs
chown root:root /certs
chmod 700 /certs
cp /var/mcRestore/certs/* /certs/

# copy postfix extra.cf
cp /var/mcRestore/opt/mailcow-dockerized/data/conf/postfix/extra.cf ./data/conf/postfix/

# copy docker-compose override
cp /var/mcRestore/opt/mailcow-dockerized/docker-compose.override.yml ./

Start mailcow

Now that our configuration is copied, we can start mailcow. We need to do this for two very important reasons:

  1. Ensure that mailcow runs properly with our restored settings but without any data; and
  2. Create empty default volumes for us to copy our data into!
docker-compose up -d && docker-compose logs -f

Quickly check the logs for errors, there shouldnt be any. When you are done reviewing your real-time logs, press ctrl-c to exit. Now, open a browser and verify that you can get to the mailcow admin page and, optionally, the SOGo homepage. If you copied certificates, it should be using those assuming you set them up properly. We only need to test front pages, it is not necessary to login or anything.

Ok, were ready to restore our data!