How To Transfer Your Website From One Web Server To Another?
It doesn’t happen too often, but there are times when you will be faced with the task of transferring your website and content from one server to another. A few reasons why you would need to do this come to mind. Perhaps your current web hosting provider lacks in good service and support. Maybe the quality of your connection is terrible. Or, maybe you have found a better deal somewhere else.
There are many reasons why you could find yourself in need to transfer your website and if you don’t know how to do it, life can quickly become miserable. Transferring your website from one server to another isn’t actually too difficult. Once your know the steps to take and how to execute them, transferring your website will be breeze.
I suspect that many people have tried to transfer their website using FTP. This method does work, but it can take a really long time. The reason why it can take a long time is because you have to download your content to your own personal computer and then upload it all back to the new server. Also, if your site runs on a database, such as WordPress and MySQL, you can’t get a copy of your database via FTP.
A better and faster way to transfer your website from one server to another is to use Secure Shell (SSH). For starters, you rule out the middleman… that’s you! Instead of downloading the copy of your website to your personal computer and uploading it to the new server, using SSH, you can bypass that process and transfer direct from your old server to the new server. This is useful for many reasons.
One immediate reason the comes to mind is that the transfer will constantly run. If you make transfers via FTP, your computer has to stay connected. The moment you shut your computer down, the connection is lost. With SSH, once you initiate the transfer, the connection between the two servers isn’t dependent on the connection of your personal computer.
Step One: Enable Secure Shell (SSH) Access
The first thing you want to do is make sure both of your web hosting accounts offer Secure Shell access. If you use HostGator, go here to enabled SSH. For BlueHost customers, go here. GoDaddy customers can go here. For all others, simply contact your web hosting provider for specific instructions on how to enable Secure Shell access.
Step Two: Download CLI / SSH Client Software
Next you will need to download a SSH client. Don’t worry… the program you need is free. There’s quite a few to choose from. Some cost money, but most are free, and will fit your needs perfectly. These programs looks similar to DOS and require similar commands. I know that many people avoid coding and programming, but honestly… using a SSH client isn’t that hard to do. It’s just a matter of knowing the right commands. And honestly, most people don’t memorize commands, they bookmark them and copy & paste them into the console. I want to share that because that was one of the main reasons why I avoided using command line programs for many years.
I assumed that I would need to actually be a programmer, and I would have to be fluent with the command and language. Once I discovered that most people don’t actually memorize the different commands and languages, I started to gain a bigger picture on how SSH can be useful to me. In fact, transferring my website from one server to another was one of the first things I learned how to do using SSH. And that’s the reason why I posted this article. It’s only a guess, but I suspect that this is one of the main reasons why many people gain an interest in using command line interface programs.
For Windows users, I recommend Putty. You can get a copy here. Choose the first option. For Mac and Linux users, your operating system already includes a program that works fine. For Mac users, open Finder, go to Applications, scroll down to Utilities and open the folder, scroll down and look for Terminal and open it. For Linux users using Ubuntu, open the Applications Menu, then open the Accessories menu, and then open Terminal.
Step Three: Login Via SSH To Your Existing Web Hosting Account
Now it’s time to start the transfer. Once again, in order to do this, you need to make sure SSH has been enabled on both web hosting accounts. Login to your existing web hosting account. The basic command to do this is:
ssh firstname.lastname@example.org or ssh username@ipaddress
Be sure to check with your web hosting provider as the commands will vary. For example, if you’re a HostGator customer, you will need to use this command:
ssh -p 2222 username@ipaddress
If you need additional support, HostGator customers can go here to learn more. For BlueHost customers, go here. Godaddy customers, go here. For all others, check with your web hosting provider for specific instructions.
Step Four: Start The Transfer
Once you are logged into your existing web hosting account, you can start the transfer process. Before you can initiate the transfer though, you need to know where your content is located on the existing server, and where you want to put the content on the new server. In most cases everything will be located in the public_html folder. You will be making the transfer using the SCP command, which stands for Secure Copy.
Type: pwd to figure out where you’re at on the server:
[garrycon@gator674 ~]$ pwd
Type: dir to figure out what directories are on your server:
[garrycon@gator674 ~]$ dir
access-logs etc mail public_ftp ruby webdisk
cgi-bin logs php.ini public_html tmp www
Type: cd public_html to “change directory” to public_html:
[garrycon@gator674 ~]$ cd public_html
Type: pwd again to verify your location on the server and to get the full address location:
[garrycon@gator674 ~/public_html]$ pwd
The address location will be needed when you enter the command to start the transfer. Verify the location you want to transfer your content to on your new server. In most cases, the location will be the same, public_html. To start the transfer use this command, but be sure to modify it to match your usernames, addresses, and locations for both servers:
scp -r folder/location/ email@example.com: /folder/
scp -r home/garrycon/public_html/ firstname.lastname@example.org: /home/garryconn/
That’s it! This will immediately start the transfer of your content from your old web server to your new one. Let me explain what this code means and what it does.
scp -r = Secure copy a directory. scp can copy individual files. scp-r is used to copy entire directories.
folder/ = The full path on your existing server to the content you want to transfer to your new server. Example, using home/garrycon/public_html/ will transfer everything in the public_html directory to the new server. If you have an add-on domain that you would like to transfer by itself, the code would be home/garrycon/public_html/add-on_domain.com/ This command will transfer the contents in your add-on_domain.com/ folder only.
email@example.com: = This is the username and address of your new server that you will be transferring your content to. This will make a secure connection from your existing server to your new server. An example is firstname.lastname@example.org:
/folder/location = This is the location where you want your content to go on the new server. In most cases this will match the existing location on your old server. public_html isn’t included is because doing so will result in your content being transfered to public_html/public_html.
This last part may be confusing, so I will explain it further. If your content is located on your existing server at /home/username/public_html and you want to transfer the public_html directory to your new server. The public_html directory should be located in your /home/username/ folder on your new server.
In other words, the entire code means this: With a secure connection, copy the directory that contains my content on the existing server. Login to my new server with a secure connection and paste the directory.
scp -r folder/ email@example.com:/folder/location
If you have any questions or need assistance, feel free to leave a comment. Keep an eye out for my next post while will explain how to transfer your MySQL database from one server to another.