I’ve made a number of server jumps in the past years (more on this in the near future) and have always used the traditional SFTP action to move my sites. For smaller sites, it’s not that big of a deal, but the larger sites can take a while!
Last week I made another server jump (hopefully the last) and after hearing a number of people recommend SSH for migrating a website from one server to another, I finally decided to give it a try. I had no idea what I was missing! What usually took me a good week to ten days, only took two weekend evenings.
Now, I shall pass this lovely bit of information to you:
How-To Migrate Your Website with SSH
First, you’ll want to wire-up your favorite SSH/Telnet app. If you’re running a Mac, you can use the built-in SSH in OS X (here’s a tutorial on that) or Windows users can use the free PUTTY app. If you are up and running with Coda 2, I recommend using the built-in SSH feature–it’s pretty slick. 🙂
You’ll also want to get your SSH login information for both servers (some providers may not offer this option, but most do).
- Login to your old server using SSH.
- Go to the directory where your website is.
To navigate using SSH, you’ll need to barrow some ol’ DOS style commands.
- dir = will list everything in the current directory.
- cd foldername = will place you in the foldername.
- cd .. = this will place you higher in your directory hierarchy–think ‘back button.’
So, if your website resides in “html” or “httpdocs” that’s more than likely the directory you’ll want to be in.
Once you’re sitting in the correct directory (folder), type the following command:
tar -cvf sitepack.tar ./
This will create a tar file of all the files in that directory as well as look cool as your entire website file listings wiz past the screen. I’ve had it hang-up before, so I just jumped-off, deleted the erroneous TAR file via SFTP and repeated the process.
After you’ve logged off your old server, log onto your new one.
Like before, navigate your way to the directory you’ll want your website to be. Again, probably “html” or “httpdocs.”
Now, it’s time to snag the TAR file you created on your old server and bring it over to your new sever:
Be sure to replace “yourdomain.com” with the domain name of the website you’re migrating! This is my favorite part of the process, as the ASCII animation shows the TAR file downloading. 😀
Once the file is safely on your new server, it’s time to open it!
tar -xvf sitepack.tar
This will “unzip” your site on your new server.
Remember, this only migrates your site files. This doesn’t move your database or any email server configurations/settings you may have. You’ll also want to make sure your .htaccess doesn’t have anything that would only relate to your previous server, as well as any folders and files that were migrated from your old server setup. No need to store unneeded files or something that could cause problems on your new server. To be on the safe side, you should also delete the TAR files you created on both your new and old server!
If you’re migrating WordPress, migrate your database, update your wp-config.php and you’re all set to change your DNS.
Now you know how to migrate your website with SSH like a boss!