3

I have two databases I connect to with drupal. Does drush sql-dump back up all databases defined in settings.php?

If not how can I create dumps of both databases?

I've attempted using the --database=db_to_backup option but it throws an error:

sh: 1: Syntax error: "&&" unexpected
Database dump failed 

Many thanks

5

If your database connection on settings.php looks like

$databases = array(
  'default' =>
  array(
    'default' =>
    array(
      'database' => 'mydatabase1',
      'username' => 'root',
      'password' => 'root',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
  'test' =>
  array(
    'default' =>
    array(
      'database' => 'mydatabase2',
      'username' => 'root',
      'password' => 'root',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

The following command will back up both the data bases;

drush sql-dump --database=default --result-file=default.sql; drush sql-dump --database=test --result-file=test.sql
  • thanks - I was using the sql name instead of the key defined in settings.php – RobotEyes Sep 22 '15 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.