Backup MX with Postfix

by Mike on March 1, 2010 · 3 comments

in Postfix Mail Server

Build a Backup MX

The primary goal of a backup machine for Postfix is that if the first one fails, mail will be collected by the secondary mail server until the primary mail server is back online.  When you build the Backup MX  be sure  to install all of the necessary applications to scan for viruses and check for SPAM as you do not want to overload the primary machine once it comes online.

DNS Records for would look like this:

IN MX 10
IN MX 20

In the illustration you can see that when the primary mail server is unavailable, automatically the mail will be sent to secondary machine which will hold all mail in the queue until the primary server is online.

Before you get too excited about building a secondary mail server as a backup think about how you want to implement the process. A Live Postfix Class can also be helpful in building the skills it takes to configure a mail server.

Spammers Love Secondary Mail Servers
In the research for this project, viewing many experiences with mail servers, one of the typical problems that many mail administrators have had is that when they created a secondary as a backup they did not prepare it as well to deal with Spam and Malware.  Spammers have discovered this and will send the Spam to the backup as it usually does not have the restrictions that the primary server does.  So, if you are going to prepare a secondary mail server, be sure to set it up completely to scan for Spam and Anti-Virus so that it is not abused.

Create a Relay

The secondary backup can be created a lot of different ways, but the one that makes the most sense is to have the backup hold the incoming mail in a queue until the primary server is back online.  There are several reasons for this. First, most companies do not have the financial resources to put into service two hardware devices of equal value.  You can save money by using the secondary machine on lower quality hardware.  Second, if you allow the secondary machine to function fully like the primary you have the problem of syncing the mail and configuration constantly.  The other factor is that most organizations will have the primary backup quickly as it is a very important part of the company.

Here is the /etc/postfix/

myhostname =
mydomain =
myorigin = $mydomain
inet_interfaces = all
mydestination =
mynetworks =
relay_domains =, $mydestination
relay_recipient_maps =
queue_run_delay = 200s
content_filter = smtp-amavis:[]:10026

One modification that you see here is that the queue_run_delay is dropped down to 200 seconds  so that you will have Postfix check the queue more often to get the mail on the way.

The is a simple set up that has a lot of advantages.


Mateus July 27, 2010 at 1:11 pm

Dear, Can I creat three mx server for receive messages? After this servers send to main server.
I’d like to creater a cluster of mx server just to receive mail (filter virus, spam ) after that send to primary where exist useres. It is possible?

Rogier Maas August 14, 2010 at 7:05 pm


Sure you can; just create 3 MX’s. List them in your DNS with equal priorities like so: IN MX 10 IN MX 10 IN MX 10

Then configure one server holding all the mailboxes and the two others as backup, receiving mail and relaying them to the first mailserver. Remember to implement spam/viruschecks on all three servers.

Good luck!

Tom Dings October 29, 2010 at 11:33 am

Works great. Thanks for all the help. And have anice weekend!

Previous post:

Next post: