https://github.com/mpchadwick/dbanon
A run anywhere database anonymizer
https://github.com/mpchadwick/dbanon
anonymizer database-anonymizer golang magento mysql-backup mysqldump pseudonymization
Last synced: about 2 months ago
JSON representation
A run anywhere database anonymizer
- Host: GitHub
- URL: https://github.com/mpchadwick/dbanon
- Owner: mpchadwick
- License: mit
- Created: 2019-03-30T19:05:54.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-07-17T21:42:52.000Z (almost 4 years ago)
- Last Synced: 2025-12-19T01:43:40.035Z (4 months ago)
- Topics: anonymizer, database-anonymizer, golang, magento, mysql-backup, mysqldump, pseudonymization
- Language: Go
- Homepage:
- Size: 1.07 MB
- Stars: 59
- Watchers: 2
- Forks: 17
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dbanon
[](https://github.com/mpchadwick/dbanon/actions) [](https://codecov.io/gh/mpchadwick/dbanon)
A run-anywhere, dependency-less database anonymizer.
## Installation
Download [the latest release from GitHub](https://github.com/mpchadwick/dbanon/releases).
## Usage
`dbanon` reads from `stdin` and writes to `stdout`.
```
mysqldump mydb | dbanon -config=myconfig.yml | gzip > mydb.sql.gz
```
The `-config` flag can use bundled configurations or point to the path of a custom configuration file.
### Configuration
#### Magento 2
`dbanon` bundles a [default Magento 2 configuration file](etc/magento2.yml). However you almost certainly won't use it directly.
At minimum, you'll first need to run the `map-eav` subcommand. This translates EAV attribute codes to their respective attribute ids.
You must feed it a `mysqldump` of `eav_entity_type` and `eav_attribute` (in that order).
```
mysqldump mydb eav_entity_type eav_attribute | dbanon -config=magento2 map-eav > ~/magento2-mapped.yml
```
`map-eav` will replace the attribute codes in the config file with attribute ids and print an updated config to `stdout`.
Next you'd run `dbanon` with the config generated by `map-eav`.
```
mysqldump mydb | dbanon -config=~/magento2-mapped.yml | gzip > mydb.sql.gz
```
Most Magento 2 databases, however, will have additional data that needs to be anonymized beyond the default bundled file.
For this you'll first want to create a new configuration file based off the bundled configuration. Instructions on customizing the configuration file are included in the "Custom Configuration" section.
#### Custom Configuration
Specify the path to your config file via the `-config` flag
```
mysqldump mydb | dbanon -config=myconfig.yml | gzip > mydb.sql.gz
```
See [the `etc` directory](etc/) for examples.
Columns are specified as key / value pairs. The value string winds up getting passed to [this function](https://github.com/mpchadwick/dbanon/blob/ade634a10bc282c06fecef115afbdd6661a94277/src/provider.go#L36), which gets random values from [`dmgk/faker`](https://github.com/dmgk/faker).
It is also possible to pass direct Faker function calls for [supported "raw providers"](https://github.com/mpchadwick/dbanon/blob/ade634a10bc282c06fecef115afbdd6661a94277/src/provider.go#L13-L17)
## Logging
`dbanon` records messages about anything notable (e.g. invalid configuration) to the file `dbanon.log` in the directory from which you run it.
**`-log-file`**
The `-log-file` flag can be used to have `dbanon` log to a different location.
```
mysqldump mydb | dbanon -config=myconfig.yml -log-file=var/dbanon.log
```
**`-log-level`**
The `-log-level` flag can be used to control the verbosity of logs. Supported values can be found [here](https://github.com/sirupsen/logrus/blob/d131c24e23baaa812461202af6d7cfa388e2d292/logrus.go#L25-L45).
```
mysqldump mydb | dbanon -config=myconfig.yml -log-level=debug | gzip > mydb.sql.gz
```
The default log level is `info`.
**`-silent`**
Logging can be disabled entirely by passing the `-silent` flag to `dbanon`
```
mysqldump mydb | dbanon -config=myconfig.yml -silent | gzip > mydb.sql.gz
```
## Profiling
`dbanon` will generate a CPU profile to the file `dbanon.prof` when passed the `-profile` flag.
```
mysqldump mydb | dbanon -profile -config=myconfig.yml >/dev/null
```
## Limitations
- Currently only supports MySQL
## Updating
`dbanon` will self-update when passed the `-update` flag
```
dbanon -update
```
## Development
### Publishing releases
Releases are published with [GoReleaser](https://goreleaser.com/).
- Create and push a tag (e.g. `git tag -a v0.6.2 -m "v0.6.2 && git push origin v0.6.2`)
- Build the `go-bindata` (e.g. `go-bindata -pkg bindata -o bindata/bindata.go etc/*`)
- Run `goreleaser` (e.g. `goreleaser release --rm-dist`)
May need to create a new GitHub token if the current one expires
https://goreleaser.com/scm/github/