Jul 19 2006

Backing Up and Restoring Drupal


Categories:

Protect Your Data and Installation

Protecting Drupal data is slightly more complicated than a locally stored, static-file website, since all the data is stored in a database. Therefore the key to backing up your data is to backup the database. Here I outline a process that works for me. I do not make any guarantees as to the correctness of this information nor will I be held responsible for any problems you encounter as a result of its use.

My System

This worked for my system setup, but it may not work for yours, therefore I am listing my specs. At the time of this writing I was running 4.7.2, mySQL 4.0.27-standard, PHP 4.4.2, and phpMyAdmin 2.6.4-pl2.

Backing Up Your Drupal Database

  • Open phpMyAdmin
  • Select Your Database
  • Click Export
  • Under Export Click "Select All" and Select "SQL"
  • Under SQL Options
    • Important: Different hosting providers use different versions of mySQL. If you are backup up a database from one host and importing it to another, make sure to match up the mySQL versions under the "SQL compatibility mode" drop-down. For example, if you are backing up a mySQL DB in a hosting environment running mySQL 4.1, and importing it into a 4.0 environment, you will need to select "MYSQL40" from the drop-down (it defaults to "NONE"). You can check your mySQL (and PHP) versions when you first log into your admin interface (ie. in cpanel on the left-hand side).
    • Select Structure, Add DROP TABLE, Add IF NO EXISTS, Add AUTO_INCREMENT VALUE and Enclose table and field names with backquotes.
    • Select Data, Complete inserts, Extended inserts and Use hexadecimal for binary fields.
  • Select Save as file
  • In File name template: _DB_your db goes here. (Here you can use any name you want)
  • In Compression specify your choice (compression recommended for large-sized files).
  • Click Go.

Restoring Your Drupal Database

  • Open phpMyAdmin
  • Select Your Database
  • Click Import (or SQL if you don't see an import tab in your environment)
  • Browse to the location of your Drupal database backup file.
  • In Compression Select the option you chose to export the database (or "autodetect").
  • In "format of imported file" select the SQL version that matches the SQL version running on the host you exported the database from.
  • Click Go. You should see a message to the effect that "x number of queries were executed successfully."
No votes yet
Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thank you for providing this tutorial

Thank you for providing the phpmyadmin backup/restore tutorial. It saved me a lot of time.

Yes indeed!

I feel a little bit safer at least having the database file on hand. Thanks for the concise step-by-step.

Hmmm

When I press the Go button, it appears to

continued

....do nothing. Should it come up with a window asking me where I want to save it?

Import via import tab

Actually there was a step missing. If your phpMyAdmin environment supports directly importing (ie. you see an "import" tab), use that. The "file to import" dialogue will be there. In environments where the import tab is disabled the importing must be done via the SQL tab.

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Textual smileys will be replaced with graphical ones.

More information about formatting options

Captcha
This question is used to make sure you are a human visitor and to prevent spam submissions.
Copy the characters (respecting upper/lower case) from the image.