Last updated on March 26, 2017
Migrate your Drupal site in 3 steps
You have a Drupal site on your WAMP, on your computer or you have it on one hosting service, and you want to move it to another.
Will this be hard?
In this post, I will describe the concepts of moving your site. I’ll also tell you how to connect to a remote hosting service so you are not driven made by your FTP disconnecting on you.
Understand what you are doing
A website is made up of three parts:
- The content management system, such as WordPress or Drupal.
- The underlying MySQL database
- And some code pointing one to the other.
- You need to move across all the files of the content management system (CMS) (WordPress or Drupal) from your old service to your new service.
- You need to create a clean MySQL database on your new hosting service and transfer across the contents of your MySQL database from your old service.
- You must point the CMS to the database (Note WP users – I think you have to point your database to the CMS – so look out for that).
Get the software to manage the interhost transfers
You need software to move the CMS and MySQL around. You can use an FTP like Filezilla to transfer your CMS – but it will take forever.
Rather download Putty and it extra functions and use psftp to transfer the files. I’ll come back to this later.
If your MySQL database is not too big, you can use PHPAdmin to download and upload at both ends.
Let the internet know what you are doing
You also must make sure that your DNS are pointing to the new site. What this means is that you must know the DNS of the new hosting service and you must go to the place that manages your domain name and put in the DNS numbers.
It usually takes 4 hours to propagate and for re-direction to take place.
Step 1: Move your content management system
If you are moving from WAMP or a local server on your own computer, go to www, find your website, and zip up everything – everything – in the folder.
Establish that your hosting service allows you to use ssh access and psftp. If they don’t allow you, move! And, ask the next service whether they give your free ssh access before you join.
Once you have established ssh access, then you will need to do three things:
- Get your host’s address which will take the form of servername.hostname.com. Find out what it is and write it down.
- Note your ssh username and password. These will be different to the ones that you use to log in to the commercial side of your host and to your website. They will also be different to the one’s you use for the MySQL database.
- Get Putty and psftp onto your machine. Put them in a folder such as c:/tools and run them from there. Make your life easier by moving the .zip file that you made above into the same folder.
To use psftp, simply click on it, give it your host’s address and supply your username and password when asked. The password gives no indication it is receiving your input. Don’t panic. Just be careful.
When you are “in”, use ls to list what is in your directory. If you are in the right place, upload your file by typing “put c:/tools/yourfilename.zip”. Let psftp run. It takes time but at least you won’t be timed out as you will be in Filezilla.
When psftp is done, you will get the cursor back > and your unzip your file with a simple “unzip yourfilename.zip”.
Another hint: if your website is called mywebsite.com, call your zip file mywebsite.com.zip so that it opens neatly into a folder called mywebsite.com. Otherwise, remember to rename your folder with your domain name.
Your content management files are now ready and waiting but they won’t work yet because you have no database.
Step 2: Move across your database
The first thing to do now is to go to your new hosting service and figure out how to set up a clean MySQL database.
Note carefully the name that it is given, the username, and the password.
Also, hunt around for Drupal installation instructions. Specifically, you want to know what you must call your host. I have one hosting service that uses “local host” and one that requires something like “mysql.websitename.com”. Find out and write it down.
Then go to your old hosting service and use PHPAdmin to export your database. This is a three step task. A) Find the database. B) Export . C) Set the name and the compression type. D) Go.
But there are TWO complications. First, you are given a choice of format. And some hosting services accept some formats and some others. The easiest way to find out is probably to make a mistake. So export. And when you find you need another format when you are importing, then start again!
The second complication is that the export procedure may add a CREATE database command that will trip the import. You can edit this command out of hand but there is a way to avoid the hassle.
When you export, there are two procedures. If you select Databases from the horizontal menu, a box comes up which lists all the databases and you choose one. This method puts in the unwanted CREATE command.
If you choose your database on the extreme left, all its contents are listed. Then choose Export and select all the tables. This procedure does NOT insert the unwanted CREATE command.
Now you have a MySQL file (in the right or wrong format – you will discover soon), got to your new hosting service, find the PHPAdmin, select your clean, new database and IMPORT the MySQL database. Wait a little while and you are done.
For clarity, you DO NOT NEED to reconcile the database names, and usernames on the two computers. That is coming next. For moving the database, you can call yourself Charlie on one and Mary on the other. That is no problem.
Step 3: Point you CMS at your database
As a last step, you need to edit your settings.php file which is under sites/all/default.
This is a read only file – so your first step is to give yourself access.
Then scroll down the file until you see the database name, username, MySQL password and host name that you used on your old system. Change these to the database name, username, MySQL password and hostname for the new system.
Note these are not the names you use to log on to your website. They are the MySQL names that you set up in Step 1.
Hint: if you are working on your own computer, make the changes before you zip up the content management files and go back later to reset them for your local copy.
If you are moving from one remote service to another, you will have to change the settings.php file more laboriously. In Putty or Filezilla, change the permissions to 777. Edit the file. Save. Change the permissions back to 444. This took me ages. So be prepared to be patient.
Test your site
With these three steps – transfer your CMS, transfer your database, fix your settings.php – your website should run on your new site.
If you have not pointed your domain name to the DNS, you need to do that now. The order that you do this in is tricky as you can only see your site at the old server or the new one, not both, though you might get a temporary address from your new hosting service.
If you have been careful, the move should have gone uneventfully, so point the domain to the new hosting service and wait four hours to see the result.