Move your online drupal site to your laptop sandbox

It will be great if we could move our online drupal site to our laptop sandbox. Firstly , It will serve as a backup , sencondly we could just do whatever with it and do some experiment to imporve it before we make the change online. This is a guide of moving drupal site.

Before moving your online drupal site into your laptop, you should setup drupal sandbox on your laptop which is described in this article.

Steps to move the drupal site

  1. Archive your online drupal directory into one file - please don't miss any drupal file, you could always unzip the drupal installation file on your laptop to check what should be included.

  2. Important notes - include the .htaccess file in the drupal directory, or you will not able to visit the drupal site after moving it.
  3. Use phpMyAdmin in the cpanel to export the online drupal database in sql format file- you should check the file settings.php under 'sites/default/' to make sure you export the right mysql database.

  4. Use FTP tools to get the step 1, step 3 archive into your local sandbox laptop.
  5. Use the phpMyAdmin in your local sandbox to create a mysql database(e.g. drupal_db) and user (e.g. drupal_user) , grant privilige to the 'drupal_user' to make sure he have the privilige to manipulate 'drupal_db'.
  6. Make a directory 'drupal' under '/opt/lampp/htdocs/' and extract the step 1 archive
  7. Use the local phpMyAdmin to import data into 'drupal_db'
  8. Go to the local directory 'sites/default' to edit the file settings.php. the modification should include:
    • '$base_url' to point to the right directory ( e.g. http://localhost/drupal)
    • '$db_url' to reflect the change name of the local mysql database - 'drupal_db' and user 'drupal_user'

Now you could login into drupal and have your online drupal site right in your laptop!

Please note that steps in this article is not limited to move the online drupal site to your local sandbox, other similiar requirement like 'change web hosting' , 'move drupal to another directory' could be done using the same steps.