Programming TipsSSH Tips

Migrating Website Files With SSH and ZIP

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.

The Source Server

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).

The Destination Server

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.

unzip example.zip

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.

Good luck!

Join the discussion One Comment

Leave a Reply

Allen Gingrich

Author Allen Gingrich

Allen has worked on the web for over a dozen years. Like many young entrepreneurs, he began with a small workspace in his basement, where he eventually formed Ideas and Pixels. The rest, well, is history. Allen enjoys fine wines, weight training, and beautiful, semantic code.

More posts by Allen Gingrich

Join the discussion One Comment

Leave a Reply