I like Web interfaces as much as the next admin but sometimes the operations you need to perform take a mighty long time and the cPanel’s own built-in Web server (Apache 1.3) times out. Alternatively, you may not have access to any Web browser at all. Or, you may be addicted to retro-styled terminals (if you’ve reconfigured your terminal window to show bright green characters on black background, it’s usually a reliable sign of the latter). Whatever the reason may be, cPanel comes with the number of scripts that you can run in your terminal and perform the same tasks that the Web interface lets you perform. And more efficiently, I might add, because all the Web interface does is invokes these scripts and passes all the needed parameters to them, which we can do just as easily from the command line. So, here is how we do it:
Everything you’ll read below assumes you have SSH root access to your server. Regardless of your use of these cPanel scripts, having SSH root access to a VPS or a dedicated server is so essential that it’s practically a given that you have it. If you don’t, it’s time to move your business elsewhere.
cPanel installs a bunch of scripts in the /scripts (which is a symlink of /usr/local/cpanel/scripts/) directory on your server. The scripts are too numerous to describe them all (621 according to
ls /scripts | wc ) but there are some of them that are most useful when used from command line. These are mostly scripts that run a very long time and don’t have much interactivity, so you can start them and go get some coffee or do other stuff.
Moving accounts from one server to another just happens to be one of those long tasks that just beg for the use of command line scripts. So, to move an entire account – the website, the email accounts, databases etc. with all the passwords and permissions kept intact we first create an archive file by running
on the old server:
where ‘account’ is the name of the account we’re moving (side note: cPanel often takes the first 8 letters of the domain name as the default and most admins just confirm it).
This will run a long time, packaging all neatly together and creating a gzipped archive file called something like
cpmove-account.tar.gz. This file will be created in the /home/ directory.
Then we copy that file to the new server.
on the new server:
scp root@old_server.com:/home/cpmove-account.tar.gz /home/
This command (scp – secure copy over SSH) will transfer the file and deposit it into the /home/ directory on the new server. All the account moving scripts are setup to look for the archives in the /home/ directory.
When the transfer is complete, run
on the new server:
This will create the home directory (/home/account/), create the user account, email accounts, databases and everything just like it was on the old server. All we have to do after that is to switch nameservers for your domain from the old server’s nameservers to the new and then (after some time has passed and everything is working well on the new server) run this
on the old server:
That will remove every trace of the site ever being on the old server.
Please note that the description below is not really intended to be a replacement of the official cPanel manual because the scripts are accepting various parameters that control the outcome of the procedure. In most cases the defaults with empty parameters do the job just fine. However, if you find yourself in a situation where you need to change account name on the new server or change the process in some other way, head straight for the cPanel’s official manual and review the parameter options you need.