You are here

function backup_migrate_drush_restore in Backup and Migrate 7.3

Same name and namespace in other branches
  1. 8.2 includes/backup_migrate.drush.inc \backup_migrate_drush_restore()
  2. 8.3 includes/backup_migrate.drush.inc \backup_migrate_drush_restore()
  3. 6.3 includes/backup_migrate.drush.inc \backup_migrate_drush_restore()
  4. 6.2 includes/backup_migrate.drush.inc \backup_migrate_drush_restore()
  5. 7.2 includes/backup_migrate.drush.inc \backup_migrate_drush_restore()

Restore to the default database.

1 string reference to 'backup_migrate_drush_restore'
backup_migrate_drush_command in includes/backup_migrate.drush.inc
Implements hook_drush_command().

File

includes/backup_migrate.drush.inc, line 168
Drush commands for backup and migrate.

Code

function backup_migrate_drush_restore($source_id = '', $destination_id = '', $file_id = '') {
  require_once dirname(__FILE__) . '/destinations.inc';
  require_once dirname(__FILE__) . '/profiles.inc';
  require_once dirname(__FILE__) . '/sources.inc';

  // Set the message mode to drush output.
  _backup_migrate_message_callback('_backup_migrate_message_drush');
  if (!backup_migrate_get_source($source_id)) {
    _backup_migrate_message("Could not find the source '@source'. Try using 'drush bam-sources' to get a list of available sources or use 'db' to backup the Drupal database.", array(
      '@source' => $source_id,
    ), 'error');
    return;
  }
  if (!($destination = backup_migrate_get_destination($destination_id))) {
    _backup_migrate_message("Could not find the destination '@destination'. Try using 'drush bam-destinations' to get a list of available destinations.", array(
      '@destination' => $destination_id,
    ), 'error');
    return;
  }
  elseif (!$file_id || !($file = backup_migrate_destination_get_file($destination_id, $file_id))) {
    _backup_migrate_message("Could not find the file '@file'. Try using 'drush bam-backups @destination' to get a list of available backup files in this destination destinations.", array(
      '@destination' => $destination_id,
      '@file' => $file_id,
    ), 'error');
    return;
  }
  drush_print(dt('Restoring will delete some or all of your data and cannot be undone. ALWAYS TEST YOUR BACKUPS ON A NON-PRODUCTION SERVER!'));
  if (!drush_confirm(dt('Are you sure you want to perform the restore?'))) {
    return drush_user_abort();
  }
  _backup_migrate_message('Starting restore...');
  $settings = array(
    'source_id' => $source_id,
  );
  backup_migrate_perform_restore($destination_id, $file_id, $settings);
}