The newest development version of Drupal's Backup and Migrate module enables automatically scheduled database backups to be emailed off-site. However, due to a bug, it takes a little work to actually make this happen. The problem is, the module doesn't properly store your preferred email address. Here's how we work it...
EDIT: JULY 16, 2009: The developers fixed this issue; there is no need for this hack now!
- Download the development version of Backup/Migrate here. (or, use the wget trick we discussed in the last post:
$wget http://ftp.drupal.org/filed/projects/backup_migrate-6.x-2.x-dev.tar.gz )
- Install it. I won't go into details here, you probably know how to enable a module.
- Go to the administrative interface for Backup & Migrate. This is through the "Content Managment" link in the administration menu.
- Now we get to the fun stuff. Go to the "Destinations" tab and create a new destination. Obviously, we'll choose "email."
- You'll notice that it asks the name for your destination, but not your email address. This is the sticky point here-- this module has a bug right now (which I've reported) that doesn't save your email address. Luckily, I've found a workaround... but first, go ahead and save this destination.
- Now, we need to directly manipulate our MySQL database. (Quick note-- I've never used Drupal with PostgreSQL; if you don't use MySQL, you'll have to figure out your own way to make this work.)
- I like to use SSH for database manipulation, but log into PHPMyAdmin if you want a GUI method for this.
- SSH Method
- Launch the MySQL console:
mysql -u <database username> -p
<enter your password>
connect <database name>;
- We need the backup_migrate_destinations table; we'll display the records in this table to make sure we don't have any typo's. Use this code:
select * from backup_migrate_destinations; this will give you a table; you should see your email address in the "name" column, and a blank in the "location" column. We'll add your email address with the SQL UPDATE command...
- ...which will be entered like this:
update backup_migrate_destinations set location='YOUR EMAIL' where type='email'; This assumes that you've only entered one email address. If you have several you'd like you use, you'll need to either identify the record using the destination id or name, which would require a slight tweak of the WHERE TYPE=... statement.
- You're set!
- PHPMyAdmin
- It's okay to be less adventurous and use the GUI option. This is simple-- find the backup_migrate_destinations table, use the browse mode to find your email record, and then edit the location field to your email address. Done!
As I've mentioned, I've reported this bug to the developer. Hopefully it'll be fixed soon, and this workaround will not be required.
I'll leave it up to you to set up a schedule. Assuming you've got cron properly set up, the module will email your backups flawlessly.