Information


How to Back Up and Restore a Drupal Installation

It could have been a disaster. It very nearly was. Had I not done a full backup of my original Drupal installation of my allergy information website before attempting an upgrade to Drupal 5.0, it really would have been a disaster.

Assumptions

  • Your website consists of a Drupal installation only, and has no subdomains. If your situation is different, use this procedure as a guide, but watch out for how you might effect the rest of the website, and act accordingly.
  • Your Drupal installation uses the MySQL database.
  • You have access to the back end of your website, and access to phpMyAdmin to administer your database.

Website Backup

Here is how I did the backup of the Drupal installation:

  1. Put your Drupal website in maintenance mode. This will prevent changes to the content by users or visitors (e.g. adding comments) while you are doing the backup.
  2. Using FileZilla (any other FTP client will do), copy all files under the home directory (usually public_html) to your personal computer. This ensures that you can revert to the original code and basic configuration (e.g. name and password of database etc.)
  3. Back up the database. Good database backup instructions can be found on the Drupal site.
    In addition to the instructions on the Drupal site, I suggest you select the “Add DROP TABLE” option under Structure so that if you need to restore your database, you do not manually have to drop tables.

That’s it! You now have a full backup. I recommend you follow step 3 regularly so that you can always restore the content of your website should disaster strike. You should also copy the directory where you keep files (such as photos used in your posts) onto your personal computer.

Website Restore

Half way through my attempt at upgrading my Drupal-based website, I found that it was a failure, and that not only did I need to revert to the original code-base, I also had to restore the database.

I followed these steps:

  1. Delete all files under public_html.
    Note: If your website consists of more than just a Drupal installation (for example, subdomains), you must be careful what you delete! Step 2 above should get you back where you started, but at this stage you really only want to delete the Drupal part of your website.
  2. Upload the backup copy of your home directory to the server.
  3. Using phpMyAdmin, drop all tables in the Drupal database. (This should not be necessary if you selected the “Add DROP TABLE” option when you did the database backup).
  4. Select the Import tab in phpMyAdmin.
  5. Import the database backup file.

Your Drupal website should now be in exactly the same state as it was when you did the backup.

You will be well advised to practice this procedure on a test server (e.g. on your personal computer) so that you know exactly what works and what doesn’t for your installation. One little mistake during the backup could make it impossible to restore your site!


Comments

No comments:

There are no comments for this post so far.

Post a comment