The process of migrating a WordPress blog from one server to another is fairly simple. I have already explained it in detail over here, and in a nutshell, we have to migrate:
- WP-content folder
- and Old database
This process can easily be done for a new or small website using a free FTP client like FileZilla or Cyberduck. But, when dealing with a large site or migrating your website to a new hosting, it’s a good idea to use ssh/sFTP to transfer files from one server to another. In my case, I was transferring the Wp-Content folder of ShoutMeLoud from private VPS to WPEngine.
My WP-content folder was around 2GB, and manually transferring the folder is time-consuming. So, I used SSH and sFTP commands to transfer files quickly. Remember that WPEngine doesn’t give SSH access, so I need to ask their support team to decompress the compressed folder. Also, if you are on shared hosting like Bluehost, you can always enable SSH access by login into your cPanel. Here is a video showing the process of enabling SSH on Bluehost (cPanel hosting).
Before the migration, I compressed the WP-content folder into a single file, as this will make the transfer easy. You can also consider compressing the entire root directory and transferring it to your new hosting. You can always use an SSH client like Putty for running the commands, or you can use Terminal on Mac OS for the same.
Here is what the process will be like:
- ssh into the old hosting server
- from the old hosting server sFTP into the new server
- Use the Put command to copy files from the old server to a new server
And, if you have never done this before but have a technical background, you will love trying this out.
Transferring files from Old Hosting to New Hosting using SSH
Open Terminal or Putty on your Mac and ssh into your old hosting server
If your port is other than the default port, use this command
ssh username@hostname -oPort=2200
Replace 2200 with the port your server uses for SSH access. Now, you can compress your entire public_html folder using the following command: (WPback.tar.gz is the compressed file name, which I want for compression).
tar -cvzf wpback.tar.gz public_html
Note: wpback.tar.gz will be the single compressed file of your public_html folder. Depending on your file size, it may take a couple of minutes to compress the folder. Once compression is done, we will sFTP to your new server from the old server terminal.
On the same terminal, type
sftp [email protected]
Type yes and enter your password to sFTP into your new hosting server from the old server. You can use the command:
- ls – list all files
- cd – change directory
- mk – make a new directory
In my case, I created a new directory with the name Test and used
to change my default working directory.
Now, simply type
and it will start transferring your backup file from the old hosting to the new hosting. This process is usually fast, and within minutes of time, you can transfer GBs of data from one server to another. In my case, it took 12 minutes to sFTP 2Gb of data from the old hosting server to new one. Now, all we need to do is decompress the transferred file on the new server. In my case, I asked WPEngine hosting support team to do it for me.
I hope this helps, and if you have any other tips to add here, feel free to let me know via comments. If you find this tutorial useful, do share it on Facebook and Google plus.