Migrating mail server from one machine to another

From Notes_Wiki
Revision as of 11:07, 15 December 2015 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb>Email_server_configuration|Email server configuration</yambe:breadcrumb> =Migrating mail server from one machine to another= Sometimes it might be necessary ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb>Email_server_configuration|Email server configuration</yambe:breadcrumb>

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 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. service httpd start
  12. chkconfig httpd on
  13. copy /home
  14. copy /etc/passwd, /etc/shadow, /etc/group
  15. copy /etc/aliases and update root alias appropriately
  16. run newaliases
  17. install logwatch
  18. ensure that posfix is installed
  19. Copy /etc/postfix/ folder from old server to new server
  20. chkconfig postfix on
  21. Set hostname in /etc/sysconfig/network
  22. Add hostname against 127.0.0.1 in /etc/hosts
  23. hostname <FQDN>
  24. service postfix restart
  25. yum -y install dovecot
  26. Copy /etc/dovecot/conf.d/10-mail.conf from old server to new server
  27. Copy /etc/dovecot/conf.d/10-master.conf from old server to new server
  28. service dovecot start
  29. chkconfig dovecot on
  30. yum -y install wget
  31. yum -y install epel-release
  32. yum -y install squirrelmail
  33. Disable selinux (setenforce 0, edit /etc/sysconfig/selinux and set SELINUX=disabled)
  34. rsync /etc/squirrelmail contents from old server to new server
  35. rsync /usr/share/squirrelmail/plugins/ from old server to new server
  36. rsync /var/www/html from old server to new server
  37. service httpd restart
  38. Add /etc/hosts entry for new server in laptop and try to open the new server with name and IP.
  39. Enable firewall on old server for blocking http(80,443), IMAP, POP3, STMP, etc. Leave only SSH access.
  40. Again sync /home
  41. Change DNS entries to point to new server. If organization has local private DNS, then perhaps that may also require changes.
  42. Check updated entries via public DNS servers after waiting for a minute or two
  43. Copy /root/.ssh/authorized_keys from old server to new server
  44. Comment /etc/host entry in laptop after DNS entry has been changed
  45. service iptables restart on new server
  46. Apply security group settings from old server to new server (HTTP, HTTPS, POP3, POP3S, SMTP, SMTPS, IMAP, IMAPS, SSH, Ping)
  47. Send test email from gmail to server and wait for receiving email on new server
  48. Send test email from new server to gmail and wait for receiving email on Gmail account
  49. stop and possibly terminate old server after few days. Elastic IP of old server can be released immediately after stopping.


<yambe:breadcrumb>Email_server_configuration|Email server configuration</yambe:breadcrumb>