Using cPanel/WHM it is very easy to transfer an existing cPanel account between servers. Coordinating this with a client who manages DNS on their own can make things a bit tricky, especially when their MX records point to the same server for webmail service.
In order to guarantee no downtime on the site, typically I copy a cPanel account over to the new server including all site files and email in advance of notifying a client it is okay to change the DNS. I also tell the site at the newly located cPanel account to continue to read and write to the original database on the old server using the server’s IP address as the host. This gives the client the flexibility to change the DNS at a time convenient for them.
Once the DNS has propagated to the new server, a bit of cleanup is required. Following the example above,
localhost.To accomplish #1 above is simple. Via SSH on the new server run the following commands
mysqladmin drop your_database_name
# Now update your site to point to localhost instead of the original server's IP
Then, from the original server run the following commands
mysqldump -u your_cpanel_user -p your_database_name | ssh your_cpanel_user@the_new_server_ip mysql your_database_name
This will minimize downtime for your users1 while updating the site to read/write from the local copy of the database now containing the newest information.
Item #2 above is equally simple via rsync from the old server
rsync -av --progress /home/your_cpanel_user/mail/ root@the_new_server_ip:/home/your_cpanel_user/mail
This command properly updates the new mail server’s mail folder for all users with the latest changes to their accounts prior to the MX record change.
It goes without saying that this work should be done very late at night. ↩
Using CentOS 5 on my VPS, I recently found that newly created cPanel accounts running cPanel/WHM 11.24 RELEASE seemed to have some trouble properly setting permissions to allow the jailshell cPanel users to access/manage their crontab.
Setting up cron jobs via cPanel’s web interface itself worked just fine, but when trying to manage a jailshell users crontab via shell, the permissions were not set up properly to allow for this.
As d4ly you can see I don’t have permission to view/edit the crontab for d4ly
d4ly@d4ly.com [~]# crontab -e
cron/d4ly: Permission denied
So as root I did the following
root@server [~]# chmod 4775 /usr/bin/crontab
root@server [~]# cd /var/spool/cron
root@server [/var/spool/cron]# chmod 0755 .
root@server [/var/spool/cron]# chown d4ly.d4ly. d4ly
root@server [/var/spool/cron]# ls -l
total 24
drwxr-xr-x 2 root root 4096 Feb 4 17:03 ./
drwxr-xr-x 13 root root 4096 Sep 9 09:51 ../
-rw------- 1 d4ly d4ly 37 Feb 4 14:54 d4ly
-rw------- 1 root root 1555 Jan 19 20:52 mailman
-rw------- 1 root root 32 Jan 11 16:42 munin
-rw------- 1 root root 485 Jan 26 13:17 root
Then I tested things out once more as d4ly
d4ly@d4ly.com [~]# crontab -e
MAILTO="d4ly"
0 0 * * * ping d4ly.com # This cron is for testing jailshell crontab editing