Mirror Setup

Mirroring the server – What is mirroring.

The SurgeMail ‘Mirror’ system allows you to link two systems together and read or deliver Email to either system and both systems will continually ‘match’ each other.


  • A live backup of your system ready to use in the case of failure.
  • Geographic backup (the mirror can be in a different location)
  • Also perfect for ‘moving’ the server to another system with zero down time.

Mirroring will work over a LAN or WAN connection and can be encrypted. Unlike using shared NFS drives there is no single point of failure in a SurgeMail Mirrored system so you have genuine fail over capability.

Do not run a load balancer in front of your mirror, it’s better that users actually connect consistently to one system or the other.

How to enable it.

Install surgemail on the mirror system.

Turn on the mirror settings on both servers, set mode to “master” on the master, and ‘slave” on the second system. Make the mirror passwords match, and set each mirror_host to point to the other system.

Issue these commands on the master:

  • tellmail reload
  • tellmail resync_config
  • tellmail resync_nwauth
  • tellmail resync
  • tellmail resync_mkdir
  • tellmail resync_folder train
  • tellmail resync_folder lets
  • tellmail resync_folder dlist

Optional things to sync:

  • tellmail resync_folder (value of g_legal_archive_path)
  • tellmail resync_archive (legal archive feature)
  • tellmail resync_att (detached attachments feature)

How to check mirroring is complete

  • tellmail mirror_analyze (this works with recent versions only)
  • Alternatively,
    • check user counts match (tellmail find “*”) or search for users in the admin tool
    • check resync status by doing a second tellmail resync and checking it doesn’t resend a huge amount of messages, examine tellmail mirror_status
    • try logging into a couple of test accounts, and compare the number of messages in a mailbox.

Example settings you need to add

Server 1: ip (master)

g_mirror_nossl "TRUE"
g_mirror_mode "master"
g_mirror_host ""
g_mirror_secret "testing"
g_mirror_config "true" 
g_mirror_live "true" 
g_mirror_repair "true" (auto repair once a month)

Server 2: ip (slave)

g_mirror_nossl "TRUE"
g_mirror_mode "slave"
g_mirror_host ""
g_mirror_secret "testing"
g_mirror_config "true"
g_mirror_live "true"

Recovery after brief failure 1-2 days

Normally you just reconnect the faulty system and they will resync.

Recovery if repaired system has clean/ereased disk

If the faulty system has been erased, then on the GOOD/complete server use the command “tellmail resync_config” and “tellmail resync” (in fact see the instructions on adding a mirror to a new system. These commands ‘send’ data to the other system, be sure to issue them on the correct server!

Recovery if system has old data from weeks in the past!

To prevent old messages re-appearing you would do this, generally these steps are not required unless the restored server has been down for more than a week.

Set g_mirror_prune_age “-1” on the repaired system.

Delete these files from the surgemail home folder /usr/local/surgemail c:\surgemail


AND from the mailbox root delete all files called __mirror.dat, e.g. (this example uses the wrong path as I don’t know what your mailbox path is)

    find /var/spool/mail/domain.name -name “__mirror.add” -type f -delete

Del/s “__mirror.add”

IN addition on the slave (the good system) you need to use the command:   
    tellmail force_resync_prune

ALSO, in surgemail.ini on the MASTER remove the setting “g_mirror_repair TRUE”, if it exists until the servers are in sync again!!!

Notes FAQ

  • When moving a server, mirror from the master to the new server, not from the current mirror if possible. If you are going from the current mirror first run the checks on it to be sure it’s complete as above.
  • Mirroring uses port 110 to communicate, make sure that is open in your firewall between master/slave in both directions.
Was this article helpful?

Related Articles