PHPackages                             druidfi/gdpr-mysqldump - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. druidfi/gdpr-mysqldump

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

druidfi/gdpr-mysqldump
======================

A drop-in replacement for mysqldump that optionally sanitizes DB fields for better GDPR conformity.

2.0.0(1y ago)487.1k↓31.3%31GPL-2.0-or-laterPHPPHP ^8.2CI passing

Since Aug 4Pushed 5mo agoCompare

[ Source](https://github.com/druidfi/gdpr-mysqldump)[ Packagist](https://packagist.org/packages/druidfi/gdpr-mysqldump)[ RSS](/packages/druidfi-gdpr-mysqldump/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (17)Used By (1)

GDPR Dump
=========

[](#gdpr-dump)

A fork of [machbarmacher/gdpr-dump](https://github.com/machbarmacher/gdpr-dump)

A drop-in replacement for mysqldump that optionally sanitizes DB fields for better GDPR conformity.

It is based on the [ifsnop/mysqldump-php](https://github.com/ifsnop/mysqldump-php) library, and can in principle dump any database that PDO supports.

How to use
----------

[](#how-to-use)

There are presently two ways of manipulating data, the first is by manipulating the actual SQL queries that are run on the server (given by the gdpr-expressions path), and the second is by replacing column output before the dump is generated (given by the gdpr-replacements option).

```
$ ../vendor/bin/mysqldump drupal --host=mariadb --user=drupal --password=xxxxxxxx users_field_data --gdpr-expressions='{"users_field_data":{"name":"uid","mail":"uid","pass":"\"\""}}' --debug-sql
...
--
-- Dumping data for table `users_field_data`
--

/* SELECT `uid`,`langcode`,`preferred_langcode`,`preferred_admin_langcode`,uid as name,"" as pass,uid as mail,`timezone`,`status`,`created`,`changed`,`access`,`login`,uid as init,`default_langcode` FROM `users_field_data` */

INSERT INTO `users_field_data` VALUES (0,'en','en',NULL,'0','','0','',0,1523397207,1523397207,0,0,'0',1);
INSERT INTO `users_field_data` VALUES (1,'en','en',NULL,'1','','1','UTC',1,1523397207,1523397207,0,0,'1',1);

```

The fields to obfuscate are passed via a `--gdpr-expressions` parameter. Note that we use `uid` expression to satisfy unique keys.

The same without obfuscation:

```
$ ../vendor/bin/mysqldump drupal --host=mariadb --user=drupal --password=xxxxxxxx users_field_data --debug-sql
...
--
-- Dumping data for table `users_field_data`
--

/* SELECT `uid`,`langcode`,`preferred_langcode`,`preferred_admin_langcode`,`name`,`pass`,`mail`,`timezone`,`status`,`created`,`changed`,`access`,`login`,`init`,`default_langcode` FROM `users_field_data` */

INSERT INTO `users_field_data` VALUES (0,'en','en',NULL,'',NULL,NULL,'',0,1523397207,1523397207,0,0,NULL,1);
INSERT INTO `users_field_data` VALUES (1,'en','en',NULL,'admin','$S$Eb6kZl.9OFjoa69Z05pzUhaZJ6vpKaGZVpnjAxxLJ7ip0zOwanEV','admin@example.com','UTC',1,1523397207,1523397207,0,0,'admin@example.com',1);

```

### Using gdpr-replacements

[](#using-gdpr-replacements)

This uses [Faker](https://fakerphp.github.io/) for most of the column sanitization.

Presently, the tool searches for the "gdpr-replacements" option, either passed as a command line argument, or as part of a [MySql options file](https://dev.mysql.com/doc/refman/8.0/en/option-files.html).

The "gdpr-replacements" option expects a JSON string with the following format

```
{"tableName" : {"columnName1": {"formatter": "formatterType", ...}, {"columnName2": {"formatter": "formatterType"}, ...}, ...}

```

Where *formatterType* is one of the following

- **name** - generates a name
- **phoneNumber** - generates a phone number
- **userName** - generates a random user name
- **password** - generates a random password
- **email** - generates a random email address
- **date** - generates a date
- **longText** - generates a sentence
- **number** - generates a number
- **randomText** - generates a sentence
- **text** - generates a paragraph
- **uri** - generates a URI
- **clear** - generates an empty string

This will replace the given column's value with Faker output.

You can also save replacements mapping to JSON file and use it with `--gdpr-replacements-file` option.

Use with Drush
--------------

[](#use-with-drush)

See [drush-gdpr-dumper](https://github.com/druidfi/drush-gdpr-dumper)

As this mimicks mysqldump, it can be use with drush, backup\_migrate and any tool that uses mysqldump. Drush example:

```
$ export PATH=/var/www/html/vendor/bin:$PATH
$ which mysqldump
/var/www/html/vendor/bin/mysqldump
$ drush sql-dump --tables-list=users_field_data --extra-dump=$'--gdpr-expressions=\'{"users_field_data":{"name":"uid","mail":"uid","init":"uid","pass":"\\"\\""}}\' --debug-sql'

```

### MySqlOptions file

[](#mysqloptions-file)

You are able to have your gdpr-expressions/replacement options set in a mysql options file. It is to appear under the `[mysqldump]` section.

So, for example, you might have `/etc/my.cnf` with the following content

```
[mysqldump]
gdpr-replacements='{"fakertest":{"name": {"formatter":"name"}, "telephone": {"formatter":"phoneNumber"}}}'

```

Status and further development
------------------------------

[](#status-and-further-development)

Currently this is a proof of concept to spark a community process. Especially the `--gdpr-expressions` option is neither handy to write for humans, nor does it scale well. Here we might need better options.

Contributors notes
------------------

[](#contributors-notes)

- Note that the project follows [PSR-2](https://www.php-fig.org/psr/psr-2/) for formatting.

TODO
----

[](#todo)

Class `\druidfi\GdprDump\Util\Path` class is copied from `symfony/filesystem:5.4.0` package. When the package `drupal/core-dev-pinned` will allow `symfony/filesystem` newer then 5.4 we can remove this class and use `symfony/filesystem` instead.

Credits
-------

[](#credits)

- [machbarmacher/gdpr-dump](https://github.com/machbarmacher/gdpr-dump)
- [ifsnop/mysqldump-php](https://github.com/ifsnop/mysqldump-php)
- [Faker](https://fakerphp.github.io/)

Other information
-----------------

[](#other-information)

This project can be found from the Packagist:

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance60

Regular maintenance activity

Popularity36

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~99 days

Total

15

Last Release

399d ago

Major Versions

1.x-dev → 2.0.0-rc12025-03-07

PHP version history (2 changes)1.0.2PHP ^7.4 || ^8.0

2.0.0-rc1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/4cd9c5f6ffd2d6019f8375ce471fd34395c78885b9b9cf22e9a97be47c875138?d=identicon)[back-2-95](/maintainers/back-2-95)

---

Top Contributors

[![back-2-95](https://avatars.githubusercontent.com/u/1140272?v=4)](https://github.com/back-2-95 "back-2-95 (48 commits)")[![bomoko](https://avatars.githubusercontent.com/u/297936?v=4)](https://github.com/bomoko "bomoko (40 commits)")[![geek-merlin](https://avatars.githubusercontent.com/u/15613398?v=4)](https://github.com/geek-merlin "geek-merlin (19 commits)")[![Jancis](https://avatars.githubusercontent.com/u/635571?v=4)](https://github.com/Jancis "Jancis (3 commits)")[![beuss](https://avatars.githubusercontent.com/u/3670731?v=4)](https://github.com/beuss "beuss (2 commits)")[![sonnykt](https://avatars.githubusercontent.com/u/167788?v=4)](https://github.com/sonnykt "sonnykt (2 commits)")[![balintbrews](https://avatars.githubusercontent.com/u/297418?v=4)](https://github.com/balintbrews "balintbrews (1 commits)")[![nick-vanpraet](https://avatars.githubusercontent.com/u/7923739?v=4)](https://github.com/nick-vanpraet "nick-vanpraet (1 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/druidfi-gdpr-mysqldump/health.svg)

```
[![Health](https://phpackages.com/badges/druidfi-gdpr-mysqldump/health.svg)](https://phpackages.com/packages/druidfi-gdpr-mysqldump)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.4k37.3k](/packages/matomo-matomo)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[php-soap/wsdl

Deals with WSDLs

173.5M12](/packages/php-soap-wsdl)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
