1 8.2 Restore install mailcow
Asif Bacchus edited this page 2 years ago

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 doesn’t 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 don’t need that file, you can delete it. Next, we’ll 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. I’ll provide a few examples here, but ultimately only you know your own particular setup. Alternatively, if you have no idea what I’m 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 shouldn’t 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, we’re ready to restore our data!