You are here

function gdpr_dump_drush_command in General Data Protection Regulation 7

Same name and namespace in other branches
  1. 8 modules/gdpr_dump/gdpr_dump.drush.inc \gdpr_dump_drush_command()

Implements hook_drush_command().

File

modules/gdpr_dump/gdpr_dump.drush.inc, line 11
This file contains the GDPR database dump command.

Code

function gdpr_dump_drush_command() {
  $commands = [];
  $options['database'] = [
    'description' => 'The DB connection key if using multiple connections in settings.php.',
    'example-value' => 'key',
  ];
  $dbUrl['db-url'] = [
    'description' => 'A Drupal 6 style database URL.',
    'example-value' => 'mysql://root:pass@127.0.0.1/db',
  ];
  $commands['gdpr-sql-dump'] = [
    'description' => 'Exports the Drupal DB as SQL using mysqldump or equivalent.',
    'bootstrap' => DRUSH_BOOTSTRAP_NONE,
    'callback' => 'drush_gdpr_sql_dump',
    'drupal dependencies' => [
      'gdpr',
      'gdpr_dump',
    ],
    'examples' => [
      'drush gdpr-sql-dump --result-file=../18.sql' => 'Save SQL dump to the directory above Drupal root.',
      'drush gdpr-sql-dump --skip-tables-key=common' => 'Skip standard tables. @see example.drushrc.php',
      'drush gdpr-sql-dump --extra=--no-data' => 'Pass extra option to dump command.',
    ],
    'options' => _gdpr_dump_sql_get_table_selection_options() + [
      'result-file' => [
        'description' => 'Save to a file. The file should be relative to Drupal root. If --result-file is provided with no value, then date based filename will be created under ~/drush-backups directory.',
        'example-value' => '/path/to/file',
        'value' => 'optional',
      ],
      'create-db' => [
        'hidden' => TRUE,
        'description' => 'Omit DROP TABLE statements. Postgres and Oracle only.  Used by sql-sync, since including the DROP TABLE statements interfere with the import when the database is created.',
      ],
      'data-only' => 'Dump data without statements to create any of the schema.',
      'ordered-dump' => 'Order by primary key and add line breaks for efficient diff in revision control. Slows down the dump. Mysql only.',
      'gzip' => 'Compress the dump using the gzip program which must be in your $PATH.',
      'extra' => 'Add custom options to the dump command.',
    ] + $options + $dbUrl,
  ];
  return $commands;
}