Migrating ISPConfig CentOS server

Recently did a full server migration with ISPConfig installed. Luckily it was within the same distro but an updated version of CentOS-4.5, had to add centos-4.5 support to ispconfig conf file prior to the install. I also made sure that I was installing the same version of ISPConfig on the new server, and upgrading to the latest once the migration was complete and the server stable.

These are just notes I took down for later reference, just in case it happens again!!

Preparation:

In preparation for the migration, create A records to point to the new server IP, for all domains to do temporary redirection:

{newhost.domain.tld} : xx.xx.xx.xx
www1.{domain.tld}    : xx.xx.xx.xx

Migration notes and Custom implementation:

  1. Secured ssh and changed port first.
  2. Converted root filesystem to lvm.
  3. Had to add centos-4.5 support to conf file prior to ispconfig install.
  4. Merge /etc/passwd, /etc/shadow, /etc/group
  5. /etc/sysconfig/network set with fqdn, also added to hosts file.
  6. Migrated Sendmail conf, access, local-host-names, virtusertable and mail data.
  7. /etc/aliases moved over.
  8. proftpd.conf and proftpd_ispconfig.conf
  9. named.conf and pri.*
  10. my.cnf moved over.
  11. httpd.conf and Vhosts_ispconfig.conf moved over.
  12. php.ini moved over.
  13. eaccelerator moved over (make sure to recreate the cache folder).
  14. mrtg installed and conf and init files moved over.
  15. rsync /var/www/*
  16. rsync /var/spool/mail/*
  17. rsync /var/spool/squirrelmail/*
  18. rsync /var/lib/squirrelmail/prefs/*
  19. import databases or rsync /var/lib/mysql/*
  20. disable ispconfig service monitoring prior to running the below script:

    file pre_sync.sh :

        #!/bin/bash

        /sbin/service httpd stop
        /sbin/service mysqld stop
        /sbin/service sendmail stop
        /sbin/service mrtg stop

        /usr/bin/rsync -azR --progress -e '/usr/bin/ssh -i ~/.ssh/rsync_key -p 22' --delete {oldhost.domain.tld}:"/var/www /var/spool/mail /var/spool/cron /var/lib/mysql /var/spool/squirrelmail /var/lib/squirrelmail/prefs" /

        /sbin/service mrtg start
        /sbin/service sendmail start
        /sbin/service mysqld start
        /sbin/service httpd start

  21. Re-enabled ispconfig service monitoring.
  22. /roots/scripts moved over.
  23. crontab items moved over.
  24. ssh authorized_keys moved over for rsync backups.
  25. php5 (libc-client-devel, pcre-devel-6.6-1) and mod_fastcgi installed for dev site.
  26. Installed Squirrelmail and added /mail alias to squirrelmail.conf
  27. added php type to php.conf, so it is available by default:

          AddType application/x-httpd-php .php .php3 .php4 .php5

    REMOVE if existing / DO NOT ADD... Conflicts with AddType.

        <Files *.php>
            SetOutputFilter PHP
            SetInputFilter PHP
        </Files>

  28. fixed error_log with:

    "an unknown filter was not added: PHP"

    Change the line in the file /home/admispconfig/ispconfig/lib/config.inc.php:

        $go_info["server"]["apache2_php"] = 'both';

    to:

        $go_info["server"]["apache2_php"] = 'addtype';

    Change a site setting in ispconfig and save it back for the new setting to be written.

  29. Log in to ISPConfig and go to Management -> Server -> Settings and change the IP address(es) there.
  30. Then go to the DNS Manager and also changes the IP addresses in the DNS records, if necessary.
  31. trac installed with admin and account plugins.
  32. awstats installed and moved over /etc/awstats/awstats.{domain}.conf and /etc/httpd/conf.d/awstats.conf .
  33. /root/ispconfig/scripts/shell/webalizer.php customized to accommodate local conf.
  34. ispconfig phpmyadmin and tools link moved over.
  35. Setup snapshot backups
  36. Setup spamassassin training -- enabled shell for web1_{admin} to run /var/www/web1/scripts/SAtrain.sh
  37. Moved custom procmail filters:
    In /root/ispconfig/isp/conf/procmailrc.master

    Add:

        INCLUDERC={PMDIR}/.custom.rc

    Check .procmailrc for:

        INCLUDERC=/var/www/web1/user/web1_{admin}/.custom.rc

    Current .custom.rc file for web1_{admin}:

        # Returned mails
        :0:
        * ^Subject.*Returned mail: see transcript for details
        mail/Return

        :0:
        * ^From.*MAILER-DAEMON@
        mail/Return

        # Delivery Warnings
        :0:
        * ^Subject.*(Warning: could not send message for past 4 hours|Delivery Status Notification)
        mail/Delivery

        # Spam
        :0:
        * ^Subject.*(\[SPAM\])
        mail/Spam

  38. Migrated over spri and prm
  39. /home/u4/{user}/html linked to /var/www/www.{domain.tld}/web for flashcards to work -- needs fixing by developer.
  40. Proxy default site to {domain.tld} for IP xx.xx.xx.xx in /var/www/sharedip/.htaccess

        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^xx\.xx\.xx\.xx$ [NC]
        RewriteRule ^(.*)$ http://www.{domain.tld}/$1 [P,L]

Final move:

  1. Updated A records:

        mail.{domain.tld}: xx.xx.xx.xx
        www.{domain.tld} : xx.xx.xx.xx

  2. disable ispconfig service monitoring.
  3. run the post_sync.sh to rsync file, database and mail. Import databases or rsync /var/lib/mysql/* leaving out mysql and ispconfig database:

    file post_sync.sh :

        #!/bin/bash

        /sbin/service httpd stop
        /sbin/service mysqld stop
        /sbin/service sendmail stop
        /sbin/service mrtg stop

        /usr/bin/rsync -azR --progress -e '/usr/bin/ssh -i ~/.ssh/rsync_key -p 22' --exclude-from=/root/scripts/migrate/exclude.txt --delete {oldhost.domain.tld}:"/var/www /var/spool/mail /var/spool/cron /var/lib/mysql /var/spool/squirrelmail /var/lib/squirrelmail/prefs" /

        /sbin/service mrtg start
        /sbin/service sendmail start
        /sbin/service mysqld start
        /sbin/service httpd start

    file exclude.txt :

        /var/lib/mysql/ispconfigdb
        /var/lib/mysql/mysql*

  4. Re-enabled ispconfig service monitoring.
  5. mailertable setup for relaying mail to {oldhost.domain.tld} on {newhost.domain.tld}
  6. Setup IP rewrite rules for forwarding to www1 on old server.
  7. Pointed remote backups to rsync from new host.

Reference:

Moving ISPconfig

Comment