Skip to content

sql:dump

Exports the Drupal DB as SQL using mysqldump or equivalent.

--create-db is used by sql-sync, since including the DROP TABLE statements interferes with the import when the database is created.

Examples

  • drush sql:dump --result-file=../18.sql. Save SQL dump to the directory above Drupal root.
  • drush sql:dump --skip-tables-key=common. Skip standard tables. See Drush configuration
  • drush sql:dump --extra-dump=--no-data. Pass extra option to mysqldump command.

Options

  • --result-file=RESULT-FILE. Save to a file. The file should be relative to Drupal root. If --result-file is provided with the value 'auto', a date-based filename will be created under ~/drush-backups directory.
  • --create-db. Omit DROP TABLE statements. Used by Postgres and Oracle only.
  • --data-only. Dump data without statements to create any of the schema.
  • --ordered-dump. Order by primary key and add line breaks for efficient diffs. Slows down the dump. Mysql only.
  • --gzip. Compress the dump using the gzip program which must be in your $PATH.
  • --extra=EXTRA. Add custom arguments/options when connecting to database (used internally to list tables).
  • --extra-dump=EXTRA-DUMP. Add custom arguments/options to the dumping of the database (e.g. mysqldump command).
  • --format[=FORMAT]. Format the result data. Available formats: csv,json,list,null,php,print-r,string,table,tsv,var_dump,var_export,xml,yaml [default: null]
  • --database[=DATABASE]. The DB connection key if using multiple connections in settings.php. [default: default]
  • --db-url=DB-URL. A Drupal 6 style database URL. For example mysql://root:pass@localhost:port/dbname
  • --target[=TARGET]. The name of a target within the specified database connection. [default: default]
  • --show-passwords. Show password on the CLI. Useful for debugging.
  • --skip-tables-key=SKIP-TABLES-KEY. A key in the $skip_tables array. @see Site aliases
  • --structure-tables-key=STRUCTURE-TABLES-KEY. A key in the $structure_tables array. @see Site aliases
  • --tables-key=TABLES-KEY. A key in the $tables array.
  • --skip-tables-list=SKIP-TABLES-LIST. A comma-separated list of tables to exclude completely.
  • --structure-tables-list=STRUCTURE-TABLES-LIST. A comma-separated list of tables to include for structure, but not data.
  • --tables-list=TABLES-LIST. A comma-separated list of tables to transfer.
  • --fields=FIELDS. Available fields: Path (path)
  • --field=FIELD. Select just one field, and force format to string.

Global Options

  • -v|vv|vvv, --verbose. Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
  • -y, --yes. Auto-accept the default for all user prompts. Equivalent to --no-interaction.
  • -l, --uri=URI. A base URL for building links and selecting a multi-site. Defaults to https://default.
  • To see all global options, run drush topic and pick the first choice.

Topics

Aliases

  • sql-dump

Legend

  • An argument or option with square brackets is optional.
  • Any default value is listed at end of arg/option description.
  • An ellipsis indicates that an argument accepts multiple values separated by a space.