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:
- Create a new VM with necessary resources
- Add elastic IP to instance if not done already
- yum -y install epel-release vim
- Mount partition to /home as desired
- Copy keys from old server to new server as authorized
- Add /etc/hosts entry in old server for pointing to new server with name
- yum -y install httpd mod_ssl
- service iptables stop
- Copy /etc/sysconfig/iptables from old to new. Do not restart firewall. Only copy the file.
- Copy /etc/httpd/conf/httpd.conf, /etc/httpd/conf.d/ssl.conf and old SSL certificates to new server
- 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).
- service httpd start
- chkconfig httpd on
- copy /home
- copy /etc/passwd, /etc/shadow, /etc/group
- copy /etc/aliases and update root alias appropriately
- run newaliases
- install logwatch
- ensure that posfix is installed
- Copy /etc/postfix/ folder from old server to new server
- chkconfig postfix on
- Set hostname in /etc/sysconfig/network
- Add hostname against 127.0.0.1 in /etc/hosts
- hostname <FQDN>
- service postfix restart
- yum -y install dovecot
- Copy /etc/dovecot/conf.d/10-mail.conf from old server to new server
- Copy /etc/dovecot/conf.d/10-master.conf from old server to new server
- service dovecot start
- chkconfig dovecot on
- yum -y install wget
- yum -y install epel-release
- yum -y install squirrelmail
- Disable selinux (setenforce 0, edit /etc/sysconfig/selinux and set SELINUX=disabled)
- rsync /etc/squirrelmail contents from old server to new server
- rsync /usr/share/squirrelmail/plugins/ from old server to new server
- rsync /var/www/html from old server to new server
- service httpd restart
- Add /etc/hosts entry for new server in laptop and try to open the new server with name and IP.
- Enable firewall on old server for blocking http(80,443), IMAP, POP3, STMP, etc. Leave only SSH access.
- Again sync /home
- Change DNS entries to point to new server. If organization has local private DNS, then perhaps that may also require changes.
- Check updated entries via public DNS servers after waiting for a minute or two
- Copy /root/.ssh/authorized_keys from old server to new server
- Comment /etc/host entry in laptop after DNS entry has been changed
- service iptables restart on new server
- Apply security group settings from old server to new server (HTTP, HTTPS, POP3, POP3S, SMTP, SMTPS, IMAP, IMAPS, SSH, Ping)
- Send test email from gmail to server and wait for receiving email on new server
- Send test email from new server to gmail and wait for receiving email on Gmail account
- 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