Backup and migrate has integration with Drush but the readme.txt has no mention on how to use it.

drush bam backup - seems to work but how do I create a zipped backup?

drush bam restore - I can't get it to work

There are 2 sources - db and files but how do I use it to restore. There are no destinations.

Please Help


supersteph’s picture


ericdfields’s picture

It works like this

drush bam-restore db manual "nodes.mysql"

The bam-restore args are source, destination, file, and file must be in quotes.

To get a list of destinations, run drush bam-destinations.

Filename must be in quotes. That took a lot of trial and error to figure out…

ericdfields’s picture

… and I only got destinations working when I applied this patch:

(how does one 'subscribe' to updates on a thread here??)

supersteph’s picture

thanks for the link to that patch! i've been wondering about that, but hadn't taken the time to search

re: drush - i would *highly* recommend upgrading to drush v3. there were evidently a ton of bugs in v2.x that have been resolved. and thank goodness for that! can you imagine going back to life without drush??

if you do upgrade, however, take note of the remarks about spaces in the readme. you will have to uncomment a line in one of the php files to allow spaces until the bam module's drush script is updated.

re: subscribing - unfortunately (afaik) there is no way to enable email notifications on this forum. i know it seems crazy...but it's true. hopefully they'll find a solution when d.o is upgraded...

ronan’s picture

Version: 6.x-2.0 » 6.x-2.x-dev
Status: Active » Fixed

The latest dev is Drush 3 compatible thanks to mikey_p #720580: Drush 3.0 doesn't allow spaces in commands so I think I can close out this ticket.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

raven_web’s picture

Thank you for that clarification ericdfields, #2 got it working for me.

charlie-s’s picture

If I wanted to run something like this via cron, to restore my database form the latest backup every day at midnight (or w/e the case may be), how could I get the filename of the latest backup?

loopduplicate’s picture

to get the name of the latest file added to a single directory:
ls -t1 | head -n1

so, to use drush to restore the latest backup from the manual backup folder, to the default database:

cd sites/default/files/backup_migrate/manual/
latestfile=$(ls -t1 | head -n1)
drush bam-restore db manual "$latestfile"

to get the name of the latest file added to a directory tree:
find . -not -type d -printf "%p\n" | sort -n | tail -1

so, to use drush to restore the latest backup from any directory in the backup_migrate folder:

cd sites/default/files/backup_migrate/
latestfile=$(find . -not -type d -printf "%p\n" | sort -n | tail -1)
drush bam-restore db manual "$latestfile"


bserem’s picture

excellent idea but I can't make it work!

[/files/backup_migrate/manual]# ls -t1 | head -n1

any ideas?

z3cka’s picture

I got tripped up over this as well because when you run, for example:

drush bam-backups scheduled

You will get something like:

 Filename                       Date                     Age     Size
 drupstage-2012-06-19T16-16-33  Tue, 06/19/2012 - 16:16  1 day   114.72 KB
 drupstage-2012-06-21T09-32-14  Thu, 06/21/2012 - 09:32  1 hour  114.36 KB
 drupstage-2012-06-19T09-05-43  Tue, 06/19/2012 - 09:05  2 days  115.84 KB
 drupstage-2012-06-18T09-46-15  Mon, 06/18/2012 - 09:46  3 days  76.59 KB
 drupstage-2012-06-18T15-00-03  Mon, 06/18/2012 - 15:00  2 days  85.39 KB
 drupstage-2012-06-20T09-48-50  Wed, 06/20/2012 - 09:48  1 day   115.22 KB

Notice that the file extension is not included in the above output. Adding .mysql did not help me because the default backup profile has "GZip" selected as the compression. This causes the backup file to have .mysql.gz as the file extension.

The command that worked for me was:

drush bam-restore db scheduled "drupstage-2012-06-19T16-16-33.mysql.gz"

I Hope that helps some one that was struggling to get this to work, like I was.

rwilson0429’s picture

Issue summary: View changes

Yelp, that helped someone, me. Thank you very much z3cka. It's an old post but the solution provided in #11 still works today (6/8/2015).

My site was down and running update or clearing the cache would get it back up. I spent a couple of hours trying to figure out how to use drush to restore from a scheduled backup. Nothing I tried worked until I stumbled upon the post above by z3cka (#11). Following the solution in #11, I was finally able to get the restore completed by running the following drush command from the scheduled backup folder:

  • drush bam-restore db scheduled "SeniorCenterofGreaterRichmond-2015-06-07T20-15-07.mysql.gz"

The restore completed and my site was up again.