This tutorial is aimed at bigger wordpress blogs and for those hosted on VPS or dedicated servers.
This tutorial should not be tried if you are not familiar with basic Linux and MySQL commands on SSH.
This tutorial is just about transferring WordPress files and Databases only. Please be informed that server configuration and other things are not discussed in it.
There are various methods available for transferring hosted wordpress blogs from one host to another, with ease. But when it comes to bigger blogs with thousands of files, over hundred even thousands of MBs MySQL database – the process can become never ending and hectic, especially if you are on a slow internet connection.
I am going to tell you a way to shift your wordpress blog with ease, in just 20 minutes (we did it practically when we moved ProPakistani from VPS.net to Wiredtree.com)
First of all make sure that your new VPS or dedicated server, with root access, has following applications installed:
Apache or any other web server
Once you have these applications installed, make sure you have added your domain on this new web server. Adding a domain through cPanel is easy, if cPanel is not available – you might need to add a domain via SSH through this tutorial.
If you don’t know what SSH is then you shouldn’t be reading this tutorial, and ask someone to make this wordpress transfer work for you.
We are assuming that you have added your domain and at this point of time you are done with server configuration and all.
Time to shift your wordpress files and databases now.
Making a Backup of MySQL database with SSH
Before we transfer files, we need to take backup of MySQL database used for wordpress.
We are making backup file now because, we will shift this backup file to new host with all other files.
Login on old host with SSH, and use following command:
database_name: Database name used for this particular wordpress installation
/home/propakistani/public_html/: this is public directory or domain root on old host.
This command will make a backup file for your MySQL database and will place it in public directory.
Caution: This is a public directory on a webserver, so leaving this database backup file here for long can be risky.
login to your new host’s server, with SSH, go to your domain’s public directory,
In our case, ProPakistani’s public directory or domain root was: /home/propakistani/public_html
Now, you are all set to transfer files from old wordpress hosting to this current folder
Use following command.
scp -r user@oldhost:/home/username/public_html/ /
Command Explanation: In this example, command will transfer all files from your old host (/var/www/html) to local working directory, i.e. /home/propakistani/public_html
parameters used in command are:
user: this is the user name on old host, it can be root for instance
oldhost: you need to replace holdhost with the IP address of old host
After asking for password, this command will start copying all the files from old host to this new host. It can take time, depending on your files’ size.
We had 600 MBs of files with over 100 MBs of database, and it took us 15 minutes to transfer all files to new host.
File Transfer Done, now what?
Now, when all your files are transferred from old host to this current host, its time to import your database backup file. (which is also transferred to new host – remember, we took a back and had placed it in public directory). Now its time to use this file.
Importing MySQL Database using SSH
we are assuming you have access to MySQL, preferably with same username/password as you had on previous host. This way, you don’t have to change anything in your wp-config.php file. If you have new username/password for MySQL, and new database name, change all the settings accordingly in wp-config.php.
Let’s start the import of MySQL database. We are assuming that your working directory is public_html, type following command in SSH
mysql -u username -p database_name < dumpfile.sql
username: MySQL Database username
database_name: MySQL database name
dumpfile.sql: Backup file for MySQL dump
And you are done!
Making sure everything is good:
At this point of time, you are done with transferring of WordPress files and databases to new host.
Let’s do the testing to make sure you have done it right. For this, we will access our wordpress blog from new host by adding IP address in windows Hosts file.
For the purpose, make a slight change in theme on new host, for instance, in the footer.php before </body> add this line “hosted on new Host” and save the file. This will help you identify if the files are served from new host or not.
Open notepad with administrative rights (you can do this with right clicking on notepad icon and selecting “run as administrator”)
Open this file: “C:\windows\system32\drivers\etc\hosts”