How do I move SurgeMail to a new machine?
There are two ways of doing this, one is basically copying all the files to the new machine. The second is by setting up a mirror and letting SurgeMail mirror itself over to the second machine.
Automatic method, using Mirroring feature
When upgrading hardware or changing operating systems you can use mirroring to move your installation without disrupting users.
- Install surgemail on the ‘new’ system
- Setup mirroring settings on both systems, the existing system will be ‘master’ the new system will be ‘slave’
- On the master issue the commands:
- tellmail resync_config
- tellmail resync_nwauth
- tellmail resync_mkdir
- tellmail resync
- Carefully check the new system is working and has all accounts/messages. Use: tellmail mirror_analyze
- Move the license key, activate your key on the new system. Best done earlier by emailing netwin with the registration number.
- Move the users across. e.g. change your DNS or IP addresses so users now connect to the new system.
- Stop both servers and swap the master/slave settings so the new system is the master.
- To ensure aliases are working on the slave copy domuser.dat from master to slave manually!
Manual method to move SurgeMail
- Install SurgeMail on new machine
- Setup anything you tailored on the original system (e.g. authent modules)
- Stop SurgeMail on new machine
- tellmail deactivate on old machine
- Stop SurgeMail on old machine
- Copy surgemail.ini from old machine to new machine /etc/surgemail.ini or \windows\surgemail.ini
- (note all other paths you need are defined in surgemail.ini, particularly g_home and mailbox_path)
- Copy the SurgeMail directory, the mail directory and the database over to new machine.
Check surgemail.ini for the paths to copy for the mail directory (g_mailbox)
The default database is nwauth which will be stored in the surgemail directory but consists of the files (nwauth.add, nwauth.txt). The exact file paths depend on your system search for “mailbox_path” and “g_home” in surgemail.ini to find the paths in question. - Check surgemail.ini and check everything is located correctly. Change all the paths if necessary
- Chown -R mail files (if on UNIX) for all mail folders etc…
- Start surgemail on new machine, check logging in etc
- tellmail activate on new machine
- If you have moved from one OS to a different OS then you should run the installer on the new server again so that it places the correct binaries on the new system.
Merging one or more domains from one SurgeMail server with Another:
- The Vdomain sections for each domain from the old system and append to surgemail.ini on the new system.
- copy mailbox_path directory tree for each domain from old to new system.
- grep nwauth.add and nwauth.txt for the domain(s) in question, and append those lines to nwauth.add on the new system.
grep xyz.com nwauth.txt nwauth.add >nwauth.append (then copy and append that file) - If you have dlist mailing lists on the old system:
- append dlist/lists.dat from old to new system.
- Copy existing dlist/listname folders and contents from old to new system.
For a large active system you might use rsync or multiple copy commands to get the two exactly in sync before the changeover (for mailbox_path data).
Moving an existing mirror pair
In this situation you must first turn off mirroring to the existing slave, remove access to it, and then commence with the regular instructions above to create a new mirror in the new system. Then finally create a new ‘mirror’ from the mirrored system after setting it as the master:
- Upgrade the existing system to the current surgemail release
- Install surgemail on the new master server
- Disable failover/user access to the existing SLAVE system, shut it down to be sure!!!
- On the existing master point g_mirror_host at the new master server ip address.
- On the new ‘master’ server configure it as a slave to the existing master:
g_mirror_nossl "TRUE" g_mirror_mode "secondary" g_mirror_host "MASTER.IP.ADDRESS" g_mirror_secret "MUSTMATCHMASTER_SECRET" g_mirror_config "true" g_mirror_live "true"
- Start mirroring from the existing master to what will ‘become’ the new 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
Wait for the mirroring to complete.
Use: tellmail mirror_status to watch progress, then when it’s complete use: tellmail mirror_analyze to check mirroring is complete.
Test the new system to ensure it’s working, manually check an account.
- remove g_mirror settings from OLD master system, and then shut it down.
- set g_mirror_host on the NEW master system to point to the NEW slave.
- set g_mirror_mode on the NEW master to “primary” and restart surgemail.
- re-assign ip addresses to move users onto the new master system.
Now add the new ‘mirror’ server. See instructions https://surgemail.com/knowledge-base/mirror-setup/ for adding a mirror.