Jul
8

Move Drupal in 5 easy steps

By Ian // // 0 Comments

moving databases

I just moved the whole blog from a development directory into the root without any hiccups. I had built the site in a secured subdirectory just in case google stumbled by from some distant referrer.

So the basic idea was to take the contents of my site in folder 'x' and move it to folder 'y', in this case the root directory.

Drupal is just as movable as any php/mysql web application, as long as you are aware of a couple of things that can get in the way. Its no secret or mystery and if you feel that it's all too confusing do some research and gather all the information you need before you start. Also go ahead and install the Backup and Migrate module to make things easier.

1. Clean things up

Before you do anything with the files or database, take the site offline in the Site Configuration section of the Drupal admin site. Also it is recommended that you turn off Clean URLs just in case the destination htaccess is not correctly configured.

Next, turn off any caching and clear the cache in the Site Performance admin page, and also choose to rebuild the theme registry of your chosen theme (especially if it creates dynamic files in the /sites/default directory.

2. Backup files

There's many ways to do this, but here's my favorite. I you use cpanel or have ssh access you can easily gzip your entire site directory then move it to another folder then decompress it... all within an instant. Or there's ftp, don't forget to transfer all the folders, including the one called sites/default that contains any uploaded files or template settings.

3. Dump the Database

This can cause some confusion, like any dynamic web application, Dupal is nothing without its database. So this is something you need to get right, luckily if you mess it up the first time, you can always go back and repeat the process.

If you have phpmyAdmin, just go an select your Drupal database and choose Export.

Keep the settings as the default and choose "gzipped" at the bottom before clicking go. Additionally, you can tick the box "Add DROP TABLE / VIEW / PROCEDURE / FUNCTION" which will overwrite any tables of the same name, this is useful if you need to repeat the process again if something goes wrong.

click to enlarge +click to enlarge

[if you have multiple mysql databases you can check the default/settings.php file to see the database that the site is using.]

Now you have everything you need to move your site.

4. Restore the database

Now I need to create a database to put the sql dump. Again, this can be done many ways including via cpanel, phpMyAdmin or command line. I choose cpanel.

Once the database is created, now I need to create a user. Make sure you make the password and username different to other server accounts for added security. Now add that user to the database with these privelidges: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES.

Now go into phpMyAdmin and select your new database and then click "import". Find the file you made at step 3 and it should populate the database with tables.

5. Update settings.php

Go to the sites/default directory and open settings.php. You will need to modify:

$db_url - Make this your new database name and user details.

$base_url - Change this to the new location of the site.

Once that's done, turn back on Clean URL's (if you use that function), caching/performance options and finally bring the site out of maintenance mode.

Now you have a fully functional Drupal site in the new location, plus the added bonus of having a dev site you can continue to use if you need it.

There you have it, you have any thing to add or if you run into trouble, let me know.

Your rating: None Average: 5 (2 votes)

User login

Let me know what you think about anything on the site...