The developer stages need their user names and email address anonymised. I did not find anything googling the subject matter. Maybe somebody developed a Drush extension for this? Any other suggestions are welcome too.

  • I've found module to anonymize user comment comment anonymizer Jan 15, 2018 at 13:13
  • @АртемИльин the module is not related. The idea is to protect the identity of site users when developers work on their experimental or developer instance of the site.
    – ñull
    Jan 16, 2018 at 11:23

3 Answers 3


You can use drush sql-sync command to sync the database and obscure email addresses and the user passwords during db deployment.

--sanitize Obscure email addresses and reset passwords in the user table post-sync.

Check drush help sql-sync for help.

  • Thanks! Good to know! However in my case the sync is produced from a daily backup using mysqldump, but I might change that system to use drush instead. Below what I did using some SQL queries.
    – ñull
    Jan 16, 2018 at 11:04

I came up with this:

drush sql-query "
  UPDATE users 
    init=CONCAT(uid,'[email protected]') 
  WHERE uid > 0;"
drush upwd User-1 --password=SecureAdminPassword

You need, drush sql-sanitize

$ drush sql-sanitize -h
Run sanitization operations on the current database. You can add more sanitization to this command by implementing hook_drush_sql_sync_sanitize().

 drush sql-sanitize                        Sanitize database without modifying any passwords.
 drush sql-sanitize                        Sanitizes database but exempts two user fields from modification.

 --db-prefix                               Enable replacement of braces in sanitize queries.
 --db-url                                  A Drupal 6 style database URL. E.g., mysql://root:[email protected]/db
 --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. Example value: user+%uid@localhost
 --sanitize-password                       The password to assign to all accounts in the sanitization operation, or "no" to keep passwords unchanged. Example value: password
 --whitelist-fields                        A comma delimited list of fields exempt from sanitization.

Aliases: sqlsan
  • I would need to write hook_drush_sql_sync_sanitize() to also sanitize the user names.
    – ñull
    Jan 17, 2018 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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