Migrating a website is a common task for any developer, one that can often grow tired with monotony. Transferring all the files from the source server to your computer, then from your computer to the destination server. But with SSH and it’s ZIP commands, moving your websites’s files to a new server can actually be very simple, and it only takes a few minutes.
Before You Start: Download PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) to SSH into your server. I also recommend using Multi-tabbed PuTTY (http://ttyplus.com/multi-tabbed-putty/) for easy management of multiple servers.
SSH into the server that you want to take the files from, then navigate to the root HTTP directory using the
cd command. Every server’s home paths are different so type
ls to list the navigable directories available.
Once you’re in your HTTP root (often named “httpdocs”), use the following code to pack everything on your website into a single zip file:
zip -r example.zip *
While it packs, SSH into your other server (this is why multitabbed PuTTY is useful).
Navigate to the HTTP folder on the new server (equivalent of “httpdocs”) using the
cd command again, and once there, execute a cURL to download the zip file you created on your old server onto your new one.
curl -o example.zip http://theolderdomain.com/example.zip
Once it finishes downloading (watch the download counter), all you have to do is unpack the zip file and the files are fully transferred.
Keep in mind that this doesn’t move the server’s databases, only the file system. If moving large database structures, use phpMyAdmin’s built in export and import features.