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
ssh [email protected]
If your port is other than the default port, use this command
ssh [email protected] -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
cd Test
to change my default working directory.
Now, simply type
put wpback.tar.gz
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.
Bro It’s sad to say this tutorial is not really helpful I got rid of searching all over the web thought you would have provided a detailed guide but sadly its not really helpful.
If its possible for you to edit can you just make it from the starting how to move from one hosting to another via ssh?? everything how putty is used and with clear images that could ease.
@Apoorv
This might be helpful” https://wphostingdiscount.com/how-to-transfer-wordpress-away-from-wpengine-via-sftp/
pls help in to know the command to transfer folder/file from once SFTP to other SFTP.
Don’t know why, but Harsh you are always there to help! 😀
Thanks.
How about if you want to transfer a folder with large total size, like 100GB, from 1 VPS to another VPS?
@Weabee
Using SSH
Give an error on sftp command
user/bin/ssh: permission denaied
Please help
All you need is this
scp -P 22 -r /some/path/* 9.22.10.139/path/on/recieving/server
Very good tutorial Harsh!
Your guide is really helpful especially for those who have slow internet connection (like in India). I’ve few questions:
Do you prefer to have a control panel in your VPS (like Cpanel)? Or you like to manage your VPS via SSH?
Very useful tutorial ,
I used SSH only for DB management yet.