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).
Old Server
- 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.
For example:
- 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.
New Server
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:
wget yourdomain.com/sitepack.tar
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.
Clean Up
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!
Eric J says
Are you no longer hosting your website on WordPress engine?
Eric Dye says
No way. ChurchMag will continue to live and breath on WP Engine (I’m in love) and I am in the process of moving some VIP projects over to it this week. As for my smaller sites or those I’m hosting for friends (keeping costs down), I’ll be keeping them on my Media Temple DV that I have, as the Live Theme product page is not built on WordPress. If that changes in the future, which it might, and I can move everything off of my DV and to a WP only solution, it will undoubtably be on WP Engine. #HEART 🙂
Eric Dye says
How are YOU liking it?
Eric J says
I am liking it a lot, the speed is quite insane compared to what I’m used to. However their tech-support does take a little longer to get back to me than what I am used to on my cheaper web host that I also use for websites for friends and clients.
I have actually had one ticket where I just closed it and resubmitted it a few days later and got a person at wordpress engine that seems to know more about what they were talking about.
Currently I only have my employer Which is the church that I have attended for 20 years and work at on WordPress Engine I think it’ll be really good if I ever leave because the website will just be able to run itself. I will not have to worry about security updates or anything like that :p.
This comment was written using Apple’s speech to text so sorry if there’s anything weird with it.
Eric Dye says
I’ve had the same experience. Although I’ve never had to resubmit anything and I’ve been happy with the quality of tech support, it can be slow sometimes.
Swift Designs says
I used to do it like a boss and get someone else to do it, haha, but this is my preferred method now.
The very first time I used this was on a small site that was about 1GB in size. I had to migrate 5 websites to a new host and the thought of FTP was daunting. It worked flawlessly and I got the 5 done in one night. I bookmarked this page a few years ago and thought it was time to leave a comment.
My only problem though is that sometimes the wget returns a 404 error. I can download the file through the browser, but not through SSH. Any thoughts on what could be going wrong?
Eric Dye says
My guess is that it is an access issue. Either your new server is getting blocked from “reaching out” or your old server is blocking the access. I would consider contacting either or both customer support for your service provider. You might also try doing this with more “safe” files like a PNG or something — just to add another clue to when you inquire with support.
Swift Designs says
Thanks for the advice Eric. I just tried it with an image and it was a no go.
I’ll look at my end first as it’s the most logical. I’ve had the same problem when trying to wget from a few different hosts, so I’m guessing the fault is my end.
Thanks again for the great guide.
Gerold says
Because this worked at first try and saved me a LOT of time, I have to thank you very much!