Skip to content

sql:sanitize

Sanitize the database by removing or obfuscating user data.

Modules may add their own operations with an event subscriber (a service tagged event_subscriber) that listens to: - Drush\Event\SanitizeConfirmsEvent: add a line to the summary shown before confirmation. - ConsoleEvents::TERMINATE: run queries or call APIs to sanitize, when the command is sql:sanitize and its exit code is 0. - ConsoleEvents::COMMAND: optionally, add options to this command. See https://www.drush.org/latest/subscribers/. Working subscribers are at https://github.com/drush-ops/drush/tree/15.x/src/EventSubscriber/sanitize

Examples

  • sql:sanitize --sanitize-password=no
  • sql:sanitize --allowlist-fields=field_biography,field_phone_number

Options

  • --sanitize-email=SANITIZE-EMAIL. The pattern for test email addresses in the sanitization operation, or no to keep email addresses unchanged. May contain replacement patterns %uid, %mail or %name. [default: user+%uid@localhost.localdomain]
  • --sanitize-password=SANITIZE-PASSWORD. By default, passwords are randomized. Specify no to disable that. Specify any other value to set all passwords to that value.
  • --ignored-roles=IGNORED-ROLES. A comma delimited list of roles. Users with at least one of the roles will be exempt from sanitization.
  • --allowlist-fields=ALLOWLIST-FIELDS. A comma delimited list of fields exempt from sanitization.

Global Options

  • -h, --help. Display help for the given command. When no command is given display help for the list command
  • --silent. Do not output any message
  • -q, --quiet. Only errors are displayed. All other output is suppressed
  • -v|vv|vvv, --verbose. Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
  • -V, --version. Display this application version
  • --ansi. Force (or disable --no-ansi) ANSI output
  • --no-ansi. Negate the --ansi option.
  • -n, --no-interaction. Do not ask any interactive question
  • --url=URL. A base URL (e.g. example.com). Used for building links, selecting a multi-site, etc.
  • -e, --env=ENV. The Environment name. [default: prod]
  • --no-debug. Switches off debug mode.

Aliases

  • sqlsan
  • sql-sanitize

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.