Thursday 31 March 2011

Drush - Backup and Migrate command documentation

Drush is an amazing command line tool for administrating Drupal. Backup and Migrate is a Drupal module which simplifies the process of backing up and restoring your Drupal database(s). When I found out that Backup and Migrate now includes Drush support, I was really excited, but then I could not find any documentation for it anywhere (at the time of writing, the documentation link on the module page was broken). Eventually I thought to try the command line, and found everything I needed in the drush help output, so thought I would post it here in case it helps others.

Commands
bam-backup - Backup the site's database with Backup and Migrate.
bam-backups - Get a list of previously created backup files.
bam-destinations - Get a list of available destinations.
bam-profiles - Get a list of available settings profiles.
bam-restore - Restore the site's database with Backup and Migrate.
bam-sources - Get a list of available sources.



bam-backup
Backup the site's database using default settings.

Examples:
drush bam-backup - Backup the default databse to the manual backup directory using the default settings.
drush bam-backup db scheduled mysettings - Backup the database to the scheduled directory using a settings profile called "mysettings"
drush bam-backup files - Backup the files directory to the manual directory using the default settings. The Backup and Migrate Files module is required for files backups.

Arguments:
source - Optional. The id of the source (usually a database) to backup. Use 'drush bam-sources' to get a list of sources. Defaults to 'db'
destination - Optional. The id of destination to send the backup file to. Use 'drush bam-destinations' to get a list of destinations. Defaults to 'manual'
profile - Optional. The id of a settings profile to use. Use 'drush bam-profiles' to get a list of available profiles. Defaults to 'default'



bam-backups
Get a list of previously created backup files.

Examples:
drush bam-backups manual - List of backup files currently in the destination called "manual"

Arguments:
destination - Required. The id of destination to list backups from. Use 'drush bam-destinations' to get a list of destinations.



bam-destinations
Get a list of available destinations.



bam-profiles
Get a list of available settings profiles.



bam-restore
Restore the site's database with Backup and Migrate.

Examples:
drush bam-restore db manual "LCC-31.03.2011-14.01.59.mysql.gz" - restore the default database using the given dump file, which can be found in the destination called "manual"

Arguments:
source - Required. The id of the source (usually a database) to restore the backup to. Use 'drush bam-sources' to get a list of sources. Defaults to 'db'
destination - Required. The id of destination to send the backup file to. Use 'drush bam-destinations' to get a list of destinations. Defaults to 'manual'
backup id - Required. The id of a backup file restore. Use 'drush bam-backups' to get a list of available backup files.



bam-sources
Get a list of available sources.



Closing Notes
I'm not sure if this is out of date or something, but in my experience you provide the name and not the id for all of the arguments.

Drupal 6 - Drush warning about orphaned actions

When I was executing drush commands, I got a warning similar to this:
WD actions: 2 orphaned actions (comment_unpublish_action, comment_publish_action) exist in the actions table. Remove orphaned actions
Solution is to use a badly-documented Drupal feature which automatically removes all orphaned actions. Simply visit the following hidden URL on your drupal site: yoursite.com/admin/settings/actions/orphan, and it will remove any orphaned actions and forward you to the Manage Actions page, where you will see they are no longer listed!


REFERENCES
https://drupal.org/node/445922#comment-2977526