Migrating mail server from one machine to another

From Notes_Wiki

Home > CentOS > CentOS 6.x > Email server configuration > Migrating mail server from one machine to another

Sometimes it might be necessary to migrate email server from one machine to another. For example in case of AWS the mail server may need migration to increase space in /home or for increasing RAM.

Following steps can be used for migrating a running mail server setup using Configuring basic SMTP, IMAP, POP and HTTP access for complete email on a single server:

  1. Create a new VM with necessary resources
  2. Add elastic IP to instance if not done already
  3. yum -y install epel-release vim
  4. Mount partition to /home as desired
  5. Copy keys from old server to new server as authorized
  6. Add /etc/hosts entry in old server for pointing to new server with name
  7. yum -y install httpd mod_ssl
  8. service iptables stop
  9. Copy /etc/sysconfig/iptables from old to new. Do not restart firewall. Only copy the file.
  10. Copy /etc/httpd/conf/httpd.conf, /etc/httpd/conf.d/ssl.conf and old SSL certificates to new server
  11. If Installing lets-encrypt SSL certificate was used copy /etc/letsencrypt from old sever to new server. Also install python2-certbot-apache on new server. Also copy crontab configuration (crontab -l on old server, crontab -e on new server).
  12. service httpd start
  13. chkconfig httpd on
  14. copy /home
  15. copy /etc/passwd, /etc/shadow, /etc/group
  16. copy /etc/aliases and update root alias appropriately
  17. run newaliases
  18. install logwatch
  19. ensure that posfix is installed
  20. Copy /etc/postfix/ folder from old server to new server
  21. chkconfig postfix on
  22. Set hostname in /etc/sysconfig/network
  23. Add hostname against 127.0.0.1 in /etc/hosts
  24. hostname <FQDN>
  25. service postfix restart
  26. yum -y install dovecot
  27. Copy /etc/dovecot/conf.d/10-mail.conf from old server to new server
  28. Copy /etc/dovecot/conf.d/10-master.conf from old server to new server
  29. service dovecot start
  30. chkconfig dovecot on
  31. yum -y install wget
  32. yum -y install epel-release
  33. yum -y install squirrelmail
  34. Disable selinux (setenforce 0, edit /etc/sysconfig/selinux and set SELINUX=disabled)
  35. rsync /etc/squirrelmail contents from old server to new server
  36. rsync /usr/share/squirrelmail/plugins/ from old server to new server
  37. rsync /var/www/html from old server to new server
  38. service httpd restart
  39. Add /etc/hosts entry for new server in laptop and try to open the new server with name and IP.
  40. Enable firewall on old server for blocking http(80,443), IMAP, POP3, STMP, etc. Leave only SSH access.
  41. Again sync /home
  42. Change DNS entries to point to new server. If organization has local private DNS, then perhaps that may also require changes.
  43. Check updated entries via public DNS servers after waiting for a minute or two
  44. Copy /root/.ssh/authorized_keys from old server to new server
  45. Comment /etc/host entry in laptop after DNS entry has been changed
  46. service iptables restart on new server
  47. Apply security group settings from old server to new server (HTTP, HTTPS, POP3, POP3S, SMTP, SMTPS, IMAP, IMAPS, SSH, Ping)
  48. Send test email from gmail to server and wait for receiving email on new server
  49. Send test email from new server to gmail and wait for receiving email on Gmail account
  50. stop and possibly terminate old server after few days. Elastic IP of old server can be released immediately after stopping.



Home > CentOS > CentOS 6.x > Email server configuration > Migrating mail server from one machine to another