Built from real-world needs
A set of Symfony Console Commands
Backup
console db-tools:backup
Restore
console db-tools:restore
Anonymize
console db-tools:anonymize
Display statistics
console db-tools:stats
Works on top of Doctrine DBAL with most popular Database vendors:
Anonymize? 🤔
Map each table's column you want to anonymize with an Anonymizer.
On Doctrine Entities, from a list of various anonymizers
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use MakinaCorpus\DbToolsBundle\Attribute\Anonymize;
#[ORM\Entity()]
#[ORM\Table(name: 'customer')]
class Customer
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
#[Anonymize(type: 'email')]
private ?string $emailAddress = null;
#[ORM\Column(length: 180, unique: true)]
#[Anonymize(
type: 'password',
['password' => '123456789']
)]
private ?string $password = null;
#[ORM\Column]
#[Anonymize(
type: 'integer',
options: ['min' => 10, 'max' => 99]
)]
private ?int $age = null;
#[ORM\Column(length: 255)]
#[Anonymize(
type: 'string',
options: ['sample' => ['none', 'bad', 'good', 'expert']]
)]
private ?string $level = null;
#[ORM\Column]
private ?\DateTime $lastLogin = null;
// ...
}
Check your config with:
console db-tools:anonymization:dump-config
Table: customer
---------------
----------- ------------ ---------------------------------------------------------------------------------
Target Anonymizer Options
----------- ------------ ---------------------------------------------------------------------------------
email email
password password
lastname lastname
firstname firstname
age age min: 10, max: 99
level string sample: [none, bad, good, expert]
----------- ------------ ---------------------------------------------------------------------------------
user@prod:~$ console db-tools:restore --list
user@preprod:~$ scp user@prod:/path/to/prod.dump /tmp/prod.dump
user@preprod:~$ console db-tools:anonymize /tmp/prod.dump
user@local:~$ scp user@preprod:/tmp/prod.dump /tmp/prod-anonymized.dump
user@local:~$ console db-tools:restore --filename /tmp/prod-anonymized.dump
Try it on our benchmark app:
PostgreSQL | SQLite | MySQL | MariaDb | |
---|---|---|---|---|
100K | ~9s | ~10s | ~32s | ~24s |
500K | ~15s | ~16s | ~1m38s | ~55s |
1000K | ~33s | ~26s | 😬 | ~1m36s |
namespace App\Anonymizer;
use MakinaCorpus\DbToolsBundle\Anonymization\Anonymizer\AbstractAnonymizer;
use MakinaCorpus\DbToolsBundle\Attribute\AsAnonymizer;
#[AsAnonymizer(
name: 'my_anonymizer', // a snake case string
pack: 'my_app', // a snake case string
description: 'Describe here if you want how your anonymizer works.'
)]
class MyAnonymizer extends AbstractAnonymizer
{
// ...
We need you to make the DbToolsBundle awesome!