-
Notifications
You must be signed in to change notification settings - Fork 48
Home
GdprDump is a tool written in PHP that can be used to create anonymized database dumps.
GdprDump Version | PHP Requirement | Maintained? |
---|---|---|
5.x (latest) | >= 8.1 | Yes |
4.x | >= 8.1 | No |
3.x | >= 7.4 | No |
2.x | >= 7.3 | No |
1.x | >= 7.0 | No |
This tool is compatible with MySQL databases. It was tested with the following databases:
- MySQL
- MariaDB
- Percona
Phar File (recommended)
A phar file is available for downloading in the releases section. This is the recommended way to install this application.
To fetch the latest version:
wget https://github.com/Smile-SA/gdpr-dump/releases/latest/download/gdpr-dump.phar
chmod +x gdpr-dump.phar
./gdpr-dump.phar --version
With Composer
It can be installed with the following command:
composer create-project --no-dev --prefer-dist smile/gdpr-dump
To use GdprDump, you must first create a configuration file (yaml format).
Example of a basic configuration file:
---
database:
host: '%env(DB_HOST)%'
user: '%env(DB_USER)%'
password: '%env(DB_PASSWORD)%'
name: '%env(DB_NAME)%'
tables:
# Dump only the schema (no data) for all tables suffixed with "_log"
'*_log':
truncate: true
# Anonymize the data of the "users" table
users:
converters:
username:
converter: 'randomizeText'
unique: true
password:
converter: 'randomizeText'
You can find other examples here (dumps a Magento database) or here (file used by functional tests).
The following command generates a database dump:
./gdpr-dump.phar config.yaml > dump.sql
Arguments:
- config_file: path to a YAML configuration file.
Options:
-
-v
: displays a progress bar to stderr. -
--dry-run
: performs a dry-run (e.g. to check if the configuration file is valid). -
--database
,--host
,--port
,--user
,--password
: database credentials options (can also be specified in the configuration file).
If you used the configuration example provided above, the database credentials can be specified as environment variables (e.g. export DB_PASSWORD=foo
), or with command-line options.
By default, the dump is sent to the standard output of the terminal (same behavior as mysqldump). This behavior can be changed in the configuration file, as documented here.