Dbanonymizer
This tool anonymize data in table fields according strategy file. Working with MySQL, MariaDB, Postgres, MSSQL. Docker is used to encapsulate all transformations and save clean host system.
Install / Use
/learn @vmikrukov/DbanonymizerREADME
dbanonymizer
This tool anonymize data in table fields according strategy file. Working with MySQL, MariaDB, Postgres, MSSQL. Docker is used to encapsulate all transformations and save clean host system.
Convenient tool to anonymize production database dump and use for developing and testing purposes.
How does it work?
This project based on pynonymizer library. Home page is here. The library replaces personally identifiable data in your database with realistic pseudorandom data.
We developed convenient docker shell to encapsulate dump anonymization process.
There are multiple data types available for replacing to faked data:
first_namelast_namenameuser_nameemailcompany_emailphone_numbercompanybscatch_phrasejobcitystreet_addresspostcodeuriipv4_privateipv4_publicfile_namefile_pathparagraphprefixrandom_intdate_of_birthfuture_datepast_datefuture_datetimepast_datetimedateuser_agentdomain_namemac_addressisbn13paragraphwordcredit_card_number
For a full list of data generation strategies, see the docs on strategyfiles
What does the tool do inside?
- Restore temporary database from dumpfile (
DUMP_INPUT_FILEenv. variable). - Anonymize temporary database with strategy file (
STRATEGY_FILEenv. variable). - Dump resulting data to file (
DUMP_OUTPUT_FILEenv. variable). - Drop temporary database.
Requirements
- Docker
- Docker-compose
mysql
- backup file in plain .sql/sql.gz (schema and data)
postgres
- backup file in plain .sql/sql.gz (schema and data)
Getting Started
Usage
- Write a strategyfile for your database
- Set environment variables in local.env file
If your dump has CREATE DATABASE statement, please make sureSTRATEGY_FILE= DUMP_INPUT_FILE= DUMP_OUTPUT_FILE= SEED_ROWS= LOCALE=DB_NAMEvariable has same db name or delete this CREATE DATABASE statement from dump file. - Choose what DB you use according your dump. Comment/Uncomment mysql or postgres section to use appropriate connection.
DB_TYPE=mysql DB_HOST=db-mysql DB_PORT=3306 DB_NAME=dl DB_USER=root DB_PASSWORD=rootpass``` - Run command
./run.sh. Script will create all needed containers and then delete it after work will be done. Anonymized dump will be placed in this path:DUMP_OUTPUT_FILE
