richardhj/privacy-dump-bundle

用于创建匿名数据库备份的Symfony扩展包

dev-main 2021-12-01 14:11 UTC

This package is auto-updated.

Last update: 2024-08-29 05:09:41 UTC


README

创建清理和匿名化的MySQL数据库备份

关于

本Symfony扩展包提供创建匿名数据库备份的工具。

它类似于mysqldump,具有额外功能,但会牺牲性能(PHP实现)。此工具的主要目的是创建匿名备份,以便符合GDPR法规。

本Symfony扩展包补充https://github.com/richardhj/privacy-dump/

特性

  • 数据转换器(在数据导出到文件之前对其进行转换)
  • 表过滤
  • 包含列表(只有这些表将被包含在备份中)
  • 排除列表(不包括在备份中)

安装

composer require richardhj/privacy-dump-bundle

配置

richardhj_privacy_dump:
  database:
    prod: # <- the name of the database
      host: localhost
      port: 3306
      user: root
      password: password
      database: test
    
      # If DSN is specified, it will override other values
      dsn: 'mysql://root:root_pass@127.0.0.1:3306/test_db'
      # DSN can be an environment variable
      dsn: '%env(DATABASE_URL)%'

  config:
    default: # <- the name of the export configuration
      tables:
        log:
          truncate: true

        user:
          converters:
            firstname:
              converter: 'anonymizeText'
            lastname:
              converter: 'anonymizeText'
            street:
              converter: 'anonymizeText'
            company:
              converter: 'anonymizeText'
            email:
              converter: 'randomizeEmail'
              cache_key: 'member_email'
              unique: true
            username:
              converter: 'randomizeEmail'
              cache_key: 'member_email'
              unique: true
            secret:
              converter: 'setNull'

可用转换器的完整文档

https://github.com/Smile-SA/gdpr-dump/blob/master/docs/01-configuration.md#dump-settings

用法

php bin/console privacy-dump prod default --filename dump.sql