Member-only story

Drupal: How to Sanitise Data With Drush

And why it’s important to do it

Sergio Guardiola Herrador
2 min readNov 8, 2021
Photo by David Pupaza on Unsplash

Data sanitisation involves the deletion on purpose of sensitive data so it can’t be recovered. This is done for example when working with a database from production in our local. That database might contain e-mails, addresses, phone numbers and other data that shouldn’t be leaked.

When working with Drupal, Drush has its own command to do this. Running the command below will sanitise users fields, delete webform submissions and truncate sessions table:

drush sql:sanitize
The following operations will be performed:

* Truncate sessions table.
* Sanitize text fields associated with users.
* Sanitize user passwords.
* Sanitize user emails.
* Truncate webform submission tables.

Do you want to sanitize the current database? (yes/no) [yes]:
> yes

[success] Sessions table truncated.
[success] No text fields for users need sanitizing.
[success] user__field_contract_number table sanitized.
[success] No text fields for users need sanitizing.
[success] No text fields for users need sanitizing.
[success] No text fields for users need sanitizing.
[success] No text fields for users need sanitizing.
[success] No text fields for users need sanitizing.
[success] user__field_first_name table sanitized.
[success] user__field_last_name table sanitized.
[success] No text…

--

--

Sergio Guardiola Herrador
Sergio Guardiola Herrador

Written by Sergio Guardiola Herrador

I write articles in English and Spanish, mostly about programming, technology, travel, money, investing. You can find me here: https://sergioguardiola.net

No responses yet