Automatically back up your Drupal site’s database

Published by | Friday, February 15th, 2013

You do back up your computer, don’t you? It’s an easy process, even if you don’t use a utility like the Apple Time Machine: you simply move a bunch of files from your one place to another.

But if you try that with your Drupal site, you’ll leave out the most important part—your site’s content and configuration. That’s because those parts live in your site’s database, which is stored far away from the site’s files. The solution is to export the database as a file, then save that file along with everything else. Doing that manually can be a pretty awkward procedure, but the Backup and Migrate module makes it easy. Here’s what I do:

  1. Install Backup and Migrate the usual way (shown in the section “Expanding a Site’s Capabilities with Modules” in Drupal 7 Essential Training).
  2. Define where you want Drupal to store private files by clicking Configuration > File  system. Be sure to secure the destination by following the link on that page. If you don’t, your raw database file could become accessible to everybody.
  3. Configure Backup and Migrate to save the database into that directory. (I set up a schedule to save it once a day.) The video Backing up with the Backup and Migrate module in Drupal 7 Advanced Training shows you how.
  4. Save that database file when you save the rest of the Drupal files.

A conservative strategy: Backup and Migrate set to save six months of backups.

 

One last step: Be sure to practice restoring from that backup to make sure it works, as a bad backup is the same as no backup! Note that this is not the same as a straightforward MySQL export: you’ll need to use the Drupal Backup and Migrate module itself to reestablish your site. But while unusual, I’ve found this procedure to be far easier (and more foolproof) than noodling with my site’s Drupal database manually.

Share this:Share on Facebook1Tweet about this on Twitter1Share on Google+0Pin on Pinterest0Share on LinkedIn0

lynda.com - start learning today

Tags: , , ,


Leave a Reply