Perfect Cpanel - Cpanel Migration steps | |
Original | Current |
Migrations are always a head ache for customers and end-users. Main Reason for this is doing migrations without proper planning. If we plan a migration then yes we can try to reduce the downtime of the sites to the least say 2 – 3 min. I agree that we might have to do migrations in a hurry like the old server is down due to hardware issues or some other bad disk issues. If the migration is not properly done and sites are live then there are chances to get the sites getting updated in the old server and after dns propagations clients will start crying saying the data is missing. As a server admin I have seen this many times due to non-planning and customers always come in a hurry to us just before old server cancellation. Main point is to Plan Migrations as early as possible and discusses the same with your Server Administrator. Here I will be discussing a cPanel - cPanel Migrations Steps which is using DNS (nameservers) pointed to the same server which is having data and also will mention how we can do if you have nameserver cluster setup. So steps will be divided into 2 criteria 1. cPanel – cPanel migration whose nameservers are using same server’s DNS installation and not having any cPanel dns only or DNS cluster setup. 2. cPanel - cPanel Migration Having DNS Cluster setup and not using server’s DNS installation I am writing this Doc when the cPanel is at Version 11.58.x and discussing the first option which is the normal case. Migrations Steps whose nameservers are using same server’s DNS installation 1. We should start preparing for migration at least 24 – 48 hours prior to actual data migration. We should check all the domains in the old server and reduce ttl value atleast 24 hours before for all domains. If any domains is using external nameservers, then inform the client about the same and get it done in their remote nameserver section. Reducing TTL value will help to reduce the time of propagation and You can google more about the same if you wish to get exactly how this will help you during migration. To reduce the TTL value please use the below steps # cd /var/named # replace 14400 300 -- *.db # replace 86400 300 -- *.db Please change the values 14400 and 84400 values as per the old server in your case. To make those changes alive, we might need to restart dns service. /scripts/restartsrv named If you are using a DNS Cluster, or using cPanel dns only servers, then please proceed the same above steps in those servers and make sure the ttl of the domains has been changed to 300 seconds which is 5 min. If you are migrating the ip’s then you can ignore this steps as there might be now use in this but I will always suggest to this done as it will help us to revert any changes if anything happens and you have to revert all back to old server. 2. Order the New server with similar partition structure as per the old server or just get a server with all space on a single / partition. If you are planning to use SSD Drive for MySQL, then Please mount either /var/lib/mysql as a separate partition. 3. Install cPanel in the new server 4. Setup the New server as per the old server Main things which a client want to get migrated will be the below ones and some might want to replicate custom setups, Binary Installations, Additional settings outside the cPanel. It is always good to ask the customer whether he has any custom settings in the old server like some custom / shared file path for his sites, custom binary installations etc. a. Apache and Php modules You can copy the Apache and php Modules using the below steps. If you have any profile saved and that is in use, then you can copy that profile from /var/cpanel/easy/apache/profile/custom/custom.yaml ( the name custom.yaml will be the name you gave while saving the profile). If you do not have any profile saved, then better use the /var/cpanel/easy/apache/profile/ _last_success.yaml First Sync the below folders and files and then do an easyapache /var/cpanel/easy/apache/custom_opt_mods/ /var/cpanel/easy/apache/prefs.yaml /var/cpanel/easy/apache/profile/ /var/cpanel/easy/apache/rawenv/ /var/cpanel/easy/apache/rawopts/ /var/cpanel/easy/apache/state.yaml # /scripts/easyapache Or If you just need Apache/php modules from the last run easy apache, then simply copy /var/cpanel/easy/apache/profile/ _last_success.yaml file from old server to new server’s /var/cpanel/easy/apache/profile/custom folder and rename the file name from _last_success.yaml to mycustom.yaml. After renaming the file, Run easy apache using the below command # /scripts/easyapache --build --profile=mycustom After completion, please compare the modules and php handler using the below commands and make sure all are migrated properly. # php –m # /usr/local/cpanel/bin/rebuild_phpconf --current b. Php.ini values (Server wide ones) If both old and new server have same version of php, then you can copy the /usr/local/lib/php.ini from old server to new server c. Mail Server settings You can take Exim Backups from old server from Home »Service Configuration »Exim Configuration Manager »Backup Tab and click “Run Backup”. Once the backups is saved in localmachine, Login to new server and go to Home »Service Configuration »Exim Configuration Manager » Restore tab and upload the backup you downloaded from old server and Click “Restore Backup”. d. MySQL Settings If the mysql versions are same you can just copy the /etc/my.cnf file from old server to new server and if mysql versions are different , then please try to use values from old server only if needed e. Mod security settings and copy custom rules Check if the old server is using any Modsec rules like Atomiccorp, Comodo or OWSAP etc and migrate all those rules and confirm all are migrated as well. Also check if any vendor installation is there in old server and copy the same vendors first and then see if there is any custom rules added. f. cPanel Tweak Settings /var/cpanel/cpanel.config contains the settings that are displayed in the interface in Tweak Settings. Copy this file to new server and replace the existing one if cPanel versions are same for both old and new server. If versions are different, just check the files differences using diff command and manually add those changes which are needed for new server. Once you made necessary changes or replace the file, then you need to restart cpanel using “/usr/local/cpanel/scripts/restartsrv_cpsrvd'” or “service cpanel restart” to fully update your server's configuration. g. Install the needed plugins after consulting with the server owner and get them licensed and installed. h. Install Firewall ( I will mention CSF here ) in the new server and copy the csf.conf , csf.allow, csf.pignore, csf.ignore, csf.deny files etc and restart firewall i. Install SSL certificate for the services like cpanel/whm/webmail/exim/ftp etc and if old cert is having good amount of validity left, then ask the client to use the old cert and change hostname to match the old one or whether he will get new cert for the new hostname. j. Other Hardening Steps done in old server and add more if there is anything which the current admin can do 5. Once you are sure the new server is setup almost similar / same as that of the old server and expect no issues after migration ask the customer for an off peak hours and get the initial Migration scheduled and perform an initial migration using cPanel Transfer tool. During cPanel migration using transfer tool, Please check the Size of the accounts in the old server and do full transfer only for those accounts whose size in less and those who is having say more than 3 GB, better method to do those migrations will be make a list of those accounts, Do a Skip home migration while initial transfer and sync the home directories of those accounts using rsync command. A good system admin might be able to write a script to get these done automatically as it needs ssh trust added for password less execution of commands, some basic scripting for syncing files and databases. 6. Once the Initial Migration process is completed ( account copy using transfer tool and sync of those account which you used skip home via transfer tool and data sync of those users using rsync command),Please ask the customer to check the sites using offline method. You can create the hosts file entry using the below command in the new server . # grep -v nobody /etc/userdomains | awk -F\: '{print $1}' | sed -r 's/(.*)/202.60.64.189 \1 www.\1/g' Some times you might need to educate the customer to how to do this check from his local PC. 7. When customer checks the sites and finds and issue , Please make sure to fix those server wide and ask customer to keep a track of changes he made related to site level or file level so that he can do those fixed after Final Sync of files and DB 8. Once this check step is completed by customer, ask him the time to do the Final Migration and then get it scheduled. 9. Prepare any Scripts needed or any changes needed to be made in the scripts made earlier for syncing. Please try to start the home sync first and db sync to be done just before dns change. So plan accordingly. You can do an additional home sync as well when you try restoring the db as well for extra secure for mails. 10. Once Final sync is completed, you can change the sites ip’s to new server using replace command in the old server # cd /var/named # replace 191.168.1.10 192.140.1.11 -- *.db # replace 191.168.1.200 192.140.1.12 -- *.db Replace the ip’s with correct one according to your old and new servers and restart named after these changes. 11. Login to the nameserver domain’s registrar control panel and change the ip’s of the nameservers to the new ones. 12. Check if all is fine from new server and make sure all is loading from new server. 13. If all is fine , then stop all the services from old server other than SSH and DNS and stop them in chkservd as well. 14. Ask the customer to keep this server for a few days so that you can sync any data if customer complains any thing missing. Also ask the customer to better to have a total server backup so that he can retrieve any thing if needed in future. 15. Change the IP / Hostname in the Nagios / Services / etc in your company if you are a server management company. I hope these steps will be fine for a normal cPanel – Cpanel server migration. Please email if you have any questions or suggestions to make on this doc so that I can make this better |
Perfect Cpanel - Cpanel Migration stepsMigrations are always a head ache for customers and end-users. Main Reason for this is doing migrations without proper planning. If we plan a migration then yes we can try to reduce the downtime of the sites to the least say 2 – 3 min. I agree that we might have to do migrations in a hurry like the old server is down due to hardware issues or some other bad disk issues. If the migration is not properly done and sites are live then there are chances to get the sites getting updated in the old server and after dns propagations clients will start crying saying the data is missing. As a server admin I have seen this many times due to non-planning and customers always come in a hurry to us just before old server cancellation.Main point is to Plan Migrations as early as possible and discusses the same with your Server Administrator. Here I will be discussing a cPanel - cPanel Migrations Steps which is using DNS (nameservers) pointed to the same server which is having data and also will mention how we can do if you have nameserver cluster setup. So steps will be divided into 2 criteria 1. cPanel – cPanel migration whose nameservers are using same server’s DNS installation and not having any cPanel dns only or DNS cluster setup. I am writing this Doc when the cPanel is at Version 11.58.x and discussing the first option which is the normal case. Migrations Steps whose nameservers are using same server’s DNS installation 1. We should start preparing for migration at least 24 – 48 hours prior to actual data migration. We should check all the domains in the old server and reduce ttl value atleast 24 hours before for all domains. If any domains is using external nameservers, then inform the client about the same and get it done in their remote nameserver section. Reducing TTL value will help to reduce the time of propagation and You can google more about the same if you wish to get exactly how this will help you during migration.
Please change the values 14400 and 84400 values as per the old server in your case. To make those changes alive, we might need to restart dns service.
If you are migrating the ip’s then you can ignore this steps as there might be now use in this but I will always suggest to this done as it will help us to revert any changes if anything happens and you have to revert all back to old server. 2. Order the New server with similar partition structure as per the old server or just get a server with all space on a single / partition. If you are planning to use SSD Drive for MySQL, then Please mount either /var/lib/mysql as a separate partition. 3. Install cPanel in the new server 4. Setup the New server as per the old server Main things which a client want to get migrated will be the below ones and some might want to replicate custom setups, Binary Installations, Additional settings outside the cPanel. It is always good to ask the customer whether he has any custom settings in the old server like some custom / shared file path for his sites, custom binary installations etc. a. Apache and Php modules First Sync the below folders and files and then do an easyapache
Or If you just need Apache/php modules from the last run easy apache, then simply copy /var/cpanel/easy/apache/profile/ _last_success.yaml file from old server to new server’s /var/cpanel/easy/apache/profile/custom folder and rename the file name from _last_success.yaml to mycustom.yaml. After renaming the file, Run easy apache using the below command
b. Php.ini values (Server wide ones) If both old and new server have same version of php, then you can copy the /usr/local/lib/php.ini from old server to new server c. Mail Server settings You can take Exim Backups from old server from Home »Service Configuration »Exim Configuration Manager »Backup Tab and click “Run Backup”. Once the backups is saved in localmachine, Login to new server and go to Home »Service Configuration »Exim Configuration Manager » Restore tab and upload the backup you downloaded from old server and Click “Restore Backup”. d. MySQL Settings If the mysql versions are same you can just copy the /etc/my.cnf file from old server to new server and if mysql versions are different , then please try to use values from old server only if needed e. Mod security settings and copy custom rules Check if the old server is using any Modsec rules like Atomiccorp, Comodo or OWSAP etc and migrate all those rules and confirm all are migrated as well. Also check if any vendor installation is there in old server and copy the same vendors first and then see if there is any custom rules added. f. cPanel Tweak Settings /var/cpanel/cpanel.config contains the settings that are displayed in the interface in Tweak Settings. Copy this file to new server and replace the existing one if cPanel versions are same for both old and new server. If versions are different, just check the files differences using diff command and manually add those changes which are needed for new server. Once you made necessary changes or replace the file, then you need to restart cpanel using “/usr/local/cpanel/scripts/restartsrv_cpsrvd'” or “service cpanel restart” to fully update your server's configuration. g. Install the needed plugins after consulting with the server owner and get them licensed and installed.
5. Once you are sure the new server is setup almost similar / same as that of the old server and expect no issues after migration ask the customer for an off peak hours and get the initial Migration scheduled and perform an initial migration using cPanel Transfer tool. During cPanel migration using transfer tool, Please check the Size of the accounts in the old server and do full transfer only for those accounts whose size in less and those who is having say more than 3 GB, better method to do those migrations will be make a list of those accounts, Do a Skip home migration while initial transfer and sync the home directories of those accounts using rsync command. A good system admin might be able to write a script to get these done automatically as it needs ssh trust added for password less execution of commands, some basic scripting for syncing files and databases. 6. Once the Initial Migration process is completed ( account copy using transfer tool and sync of those account which you used skip home via transfer tool and data sync of those users using rsync command),Please ask the customer to check the sites using offline method. You can create the hosts file entry using the below command in the new server . # grep -v nobody /etc/userdomains | awk -F\: '{print $1}' | sed -r 's/(.*)/202.60.64.189 \1 www.\1/g' Some times you might need to educate the customer to how to do this check from his local PC. 7. When customer checks the sites and finds and issue , Please make sure to fix those server wide and ask customer to keep a track of changes he made related to site level or file level so that he can do those fixed after Final Sync of files and DB 8. Once this check step is completed by customer, ask him the time to do the Final Migration and then get it scheduled. 10. Once Final sync is completed, you can change the sites ip’s to new server using replace command in the old server
11. Login to the nameserver domain’s registrar control panel and change the ip’s of the nameservers to the new ones. 12. Check if all is fine from new server and make sure all is loading from new server. 13. If all is fine , then stop all the services from old server other than SSH and DNS and stop them in chkservd as well. 14. Ask the customer to keep this server for a few days so that you can sync any data if customer complains any thing missing. Also ask the customer to better to have a total server backup so that he can retrieve any thing if needed in future. 15. Change the IP / Hostname in the Nagios / Services / etc in your company if you are a server management company.
Please email if you have any questions or suggestions to make on this doc so that I can make this better
|
|