Backup MX with MySQL (and ISPConfig) 3

Anyone who operates a Backup MX should, ensure that it´s configured identical to the actual terms of the accepted messages on the normal MX. Otherwise, the backup MX could for example accept an email for that the actual MX will not accept.

Since I use ISPConfig, all relevant data for the mail server are stored in a MySQL database. In what way the database is kept on the backup server does not matter. I use a simple MySQL master-slave replication. The described setup works well with other systems, as long as the data is stored in a database. Only the appropriate files for the MySQL access may need to be adjusted. I take this from the mail server, and update only to the MySQL user and password. While this can also be solved differently (i.e. so), I find the solution through a database better, since so changes are available ad hoc.

To make it easier I will call the mail server Cicero and the Backup-MX (nomen est omen) Tiro.

The mail server (Cicero) does not accept any mail, but only for my own domains and the matching addresses. Tiro must therefore be able to access the same data in order to identify the recipient as lawful. Since the data are stored in a database, it can be realized easily. You have to adjust only individual sql files.

Cicero is by ISPConfig configured to the requests made ​​by postfix by MySQL. Due to the replication of the database is also available on Tiro. What is missing on Tiro is an appropriate MySQL user who has the appropriate rights to the database.
CREATE USER 'backup-mx'@'localhost' IDENTIFIED BY 'TOPSECRET';
GRANT SELECT ON dbispconfig.* TO 'backup-mx'@'localhost';

Postfix should forward the e-mails only, so that the is short:

myhostname =
mydomain =
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname
smtpd_banner = $myhostname - MX Backup
biff = no
alias_maps =
relay_domains = mysql:/etc/postfix/, $mydomain
relay_recipient_maps = mysql:/etc/postfix/, mysql:/etc/postfix/,

queue_run_delay = 200s
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks,
smtpd_helo_required = yes
disable_vrfy_command = yes
smtpd_data_restrictions =
setgid_group = maildrop
queue_directory = /var/spool/postfix
daemon_directory = /usr/lib/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
relayhost =
mailbox_size_limit = 0
message_size_limit = 0

So that Postfix can access a MySQL database, we create a corresponding file (relay_domains und relay_recipient_maps), which contains the necessary information for the database access. I copied the files

from Cicero to tiro:/etc/postfix and adapted to the mysql user and password accordingly. (user = and password =).

Now you just need the proper entry in the DNS 120   MX  10 120   MX  20

That’s it – if Cicero can not be reached, mails are sent to Tiro and then go from there to Cicero.

Leave a comment

Your email address will not be published. Required fields are marked *

3 thoughts on “Backup MX with MySQL (and ISPConfig)

  • jbbr

    Hallo, vielen Dank für die Anleitung.

    Ich vermute es fehlt noch der “relayhost =” Eintrag? Oder wie weiß typo, wohin er die Mails weiterleiten soll?

  • Delawrius Butticus

    While I think this is an excellent post, the content isn’t dated, nor are versions mentioned. This makes it impossible to tell how relevant this is. Is this ISPConfig 3?

    You also don’t mention how postfix will access ISPConfig’s configuration database so it ‘knows’ which ISPConfig-controlled