PHPackages                             ashleyhindle/private-dump - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ashleyhindle/private-dump

ActiveProject

ashleyhindle/private-dump
=========================

CLI script to dump your MySQL database, and sanitise the output of sensitive data for development/staging use

v0.2.2(2y ago)681[6 issues](https://github.com/carandclassic/private-dump/issues)MITPHPPHP ^7.3|^8.0|^8.1|^8.2CI failing

Since Jan 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/carandclassic/private-dump)[ Packagist](https://packagist.org/packages/ashleyhindle/private-dump)[ RSS](/packages/ashleyhindle-private-dump/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (6)Versions (22)Used By (0)

Private Dump
============

[](#private-dump)

Private Dump is a CLI tool which can create an anonymised dump of your MySQL database, usually for development or staging use.

It accomplishes this by reading a JSON configuration file which maps out which table columns should be modified and how.

[![travis-ci-build-status](https://camo.githubusercontent.com/f5a17f4eec442e4f6093381024f16d20248a4c8bfcdad6fe152d5690de57c7c3/68747470733a2f2f7472617669732d63692e636f6d2f636172616e64636c61737369632f707269766174652d64756d702e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/f5a17f4eec442e4f6093381024f16d20248a4c8bfcdad6fe152d5690de57c7c3/68747470733a2f2f7472617669732d63692e636f6d2f636172616e64636c61737369632f707269766174652d64756d702e7376673f6272616e63683d6d6173746572) [![styleci-status](https://camo.githubusercontent.com/b39e2064aea604a036ed34910a05262bf37019d675c8f12e829fb27eba59aa36/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3136363537393835392f736869656c64)](https://camo.githubusercontent.com/b39e2064aea604a036ed34910a05262bf37019d675c8f12e829fb27eba59aa36/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3136363537393835392f736869656c64)

Private Dump requires PHP &gt;= 7.3

Table of Contents
=================

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Configuration File](#configuration-file)
    - [Key Value Tables](#key-value-tables)
- [Replacements](#replacements)
    - [Text](#text)
    - [Dates](#dates)
    - [Internet](#internet)
    - [Random](#random)
    - [User](#user)
    - [Payment](#payment)
    - [Company](#company)
    - [Miscellaneous](#miscellaneous)
    - [Barcodes](#barcodes)
- [Transformers](#transformers)
- [Notes](#notes)
- [Dev Steps](#dev-steps)
- [Release Process](#release-process)

Installation
============

[](#installation)

Install with [Composer](https://getcomposer.org/)

```
composer require ashleyhindle/private-dump

```

Install with [curl](https://curl.haxx.se/)

```
curl -Lo private-dump https://github.com/cazana/private-dump/releases/download/v0.1.1/private-dump
chmod a+x private-dump
```

Usage
=====

[](#usage)

When private-dump is ran with a valid configuration it will output the dump to stdout, allowing you to redirect it to a file, or pipe it to another program (for compression, transfer, encryption, etc..).

First, create a [configuration file](#configuration-file) manually or from an [example config](configs/), then:

**Composer**:

- `vendor/bin/private-dump.phar -c private-dump.json > /backups/mysql-backup-with-sensitive-data-overwritten.sql`

**Curl**:

- `private-dump -c private-dump.json > /backups/mysql-backup-with-sensitive-data-overwritten.sql`

You can also override the MySQL username, password and hostname from the command line:

**Composer**:

```
vendor/bin/private-dump.phar -c private-dump.json -u bigben -p bingbong -h rds-213121231-13gb.amazon.com > /backups/mysql-backup-with-sensitive-data-overwritten.sql
```

**Curl**:

```
private-dump -c private-dump.json -u bigben -p bingbong -h rds-213121231-13gb.amazon.com > /backups/mysql-backup-with-sensitive-data-overwritten.sql
```

*Note*: It's best not to pass the password on the command line as it can be seen in the process list, and will exist in the user's history.

Configuration File
==================

[](#configuration-file)

The configuration file is a JSON dictionary containing:

- database connection details
- list of databases to dump
- list of tables with replacements or transformers
    - Seeder - one column can be used as a row-seeder to get repeatability in consecutive dumps
    - keepers - some rows can be kept as is, if a specified column matches a regular expression
    - columns with replacements or transformers
    - options to restrict output
        - `where` - Added to the query when retrieving data to dump: `... WHERE xxx...`
        - `limit` - Added to the query when retrieving data to dump: `... LIMIT xxx...`

An example configuration, and configurations for popular applications, exist in the [configs](configs/) directory.

**Annotated Example Configuration - private-dump.json**

```
{
    "connection": { -- Database connection details
        "username": "bigben",
        "password": "bingbong",
        "hostname": "192.168.56.81"
    },
    "databases": { -- Databases to dump - databases not present will not be dumped
        "databaseName": {  -- All tables in this database are dumped
            "tableName": { -- Referenced tables allow replacements
                "email_address": "@email", -- Column and its replacement
                "full_name": "@fullName",
                "is_active": 0, --  Column with hardcoded value
                "$options": { -- Special options array for limit/where
                    "where": "last_login > NOW() - INTERVAL 1 WEEK",
                    "limit": 25
                }
            }
        },
        "databaseTwo": {}, -- Dump entire database and tables, with no replacements
        "databaseThree": {
            "users": {
                "$options": { -- Only options to limit data, no replacements
                    "where": "is_active=1"
                }
            }
        }
        "databaseThree": {
            "users": {
                "@seed": "id", -- Seed each row using user id, to get repeatability
                "@keepif": { -- Keep all rows with emails using domain @ourdomain.com intact
                    "column": "email",
                    "regex": "^.*@ourdomain.com$"
                }
                "first_name": "@user(current_user).firstName",
                "last_name": "@user(current_user).lastName",
                "email": "@user(current_user).email", - email will be based on the first and last names
            }
        }
    }
}

```

#### Key Value Tables

[](#key-value-tables)

Private Dump supports replacing values in a key-value store, by using an array in the configuration file to link the `value` column with the `key` column as below:

```
{
    "connection": {...},
    "databases": {
        "wordpress": {
            "wp_options": {
                "option_value": {
                    "$link": "option_name",
                    "$transformers": {
                        "admin_email": "@email",
                        "mailserver_pass": "@password",
                        "autoload": "yes"
                    }
                }
            }
        }
    }
}
```

This is a bit more complicated than the standard replacements, but offers a lot of flexibility for anonymising all types of data.

Replacements
============

[](#replacements)

The vast majority of these are made possible by the amazing [Faker library](https://github.com/fzaninotto/Faker). Most formatters listed in [Faker's documentation](https://github.com/fzaninotto/Faker#formatters) are supported in Private Dump's configuration file

All replacements below should be prefixed with an `@` as in the [example configuration files](configs).

If you need to use a hardcoded value (active=0, completed=1) you can do this by omitting the `@`: `"active": 0` in the configuration file.

You can pass variables to commands as such `@numberBetween|100,1000`

#### Text

[](#text)

- `original` - The original value, useful to use with modifiers
- `string` - Random length string up to 255 characters
- `realText` - Quotes from books
- `loremSentence` - 1 sentence of Lorem
- `loremParagraph` - 3 sentences of Lorem
- `loremParagraphs` - 3 paragraphs of Lorem

#### Dates

[](#dates)

- `iso8601` - 2019-01-20
- `iso8601Recent` - ISO 8601 date in the last 3 months

#### Internet

[](#internet)

- `email` -
- `url` -
- `ipv4`
- `ipv6`
- `userAgent`
- `domainName` - bigben.net
- `slug` - big-ben-bing-bong

#### Random

[](#random)

- `randomDigit` - singular digit
- `randomNumber` - up to 8 digits
- `randomLetter`
- `randomString` - Random length string up to 255 characters

#### User

[](#user)

- `firstName`
- `lastName`
- `title` - Ms. Mr. Dr.
- `fullName` - Brian May
- `fullAddress` - One line: Building number, street, city, state/county, postcode/zip
- `buildingNumber` - 368
- `streetName` - Broadway
- `streetAddress` - 368 Broadway
- `city` - London
- `postcode` - SW1A 0AA
- `country` - England
- `state` - Texas
- `county` - London
- `latitude` - 51.5008
- `longitude` - `-.1246`
- `phoneNumber`
- `email` -
- `username` - BigBen
- `password`
- `url` -
- `ipv4` - IPv4 Address
- `ipv6` - IPv6 Address

#### Payment

[](#payment)

- `creditCardType` - Mastercard
- `creditCardNumber` - 4444 1111 2222 3333
- `creditCardExpirationDate` - 04/22
- `creditCardExpirationDateString` - '04/13'
- `iban` - BI6B3N8497112740YZ575DJ28BP4
- `swiftBicNumber` - BIGBEN22263

#### Company

[](#company)

- `company` - Company-Name
- `jobTitle` - Croupier

#### Miscellaneous

[](#miscellaneous)

- `boolean`
- `md5`
- `sha1`
- `sha256`
- `countryCode` - UK
- `currencyCode` - EUR

#### Barcodes

[](#barcodes)

- `barcodeEan13`
- `barcodeEan8`
- `barcodeIsbn13`
- `barcodeIsbn10`

Transformers
============

[](#transformers)

- `uppercase`
- `lowercase`

---

*These notes are mainly for my own development use, feel free to ignore.*

Dev Steps
=========

[](#dev-steps)

1. Install [Box](https://box-project.github.io/box2/)
2. Modify PHP configuration to set `phar.readonly = Off`
3. `box build`
4. `chmod a+x bin/private-dump.phar`

Release Process
===============

[](#release-process)

1. Build the PHAR: `box build`
2. Rename the PHAR: `mv bin/private-dump.phar ./private-dump`
3. Update the version in `README.md`'s installation instructions based on the next version from `git tag --list`
4. Tag the next release: `git tag -a vx.x.x -m "Release x.x.x"`
5. Push: `git push origin --tags`
6. [Edit release on GitHub](https://github.com/cazana/private-dump/releases/) attaching the newly created `bin/private-dump` file

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 57.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~145 days

Recently: every ~186 days

Total

12

Last Release

1067d ago

PHP version history (3 changes)v0.0.1PHP ^5.6||^7.0

v0.1PHP ^7.3||^8.0

v0.2PHP ^7.3|^8.0|^8.1|^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/454975?v=4)[Ashley Hindle](/maintainers/ashleyhindle)[@ashleyhindle](https://github.com/ashleyhindle)

---

Top Contributors

[![ashleyhindle](https://avatars.githubusercontent.com/u/454975?v=4)](https://github.com/ashleyhindle "ashleyhindle (52 commits)")[![danielsimkus](https://avatars.githubusercontent.com/u/8949315?v=4)](https://github.com/danielsimkus "danielsimkus (22 commits)")[![thomas-brx](https://avatars.githubusercontent.com/u/361840?v=4)](https://github.com/thomas-brx "thomas-brx (16 commits)")

---

Tags

anonymisegdprmysql-backupmysqldumpphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ashleyhindle-private-dump/health.svg)

```
[![Health](https://phpackages.com/badges/ashleyhindle-private-dump/health.svg)](https://phpackages.com/packages/ashleyhindle-private-dump)
```

###  Alternatives

[knuckleswtf/scribe

Generate API documentation for humans from your Laravel codebase.✍

2.3k12.2M45](/packages/knuckleswtf-scribe)[n98/magerun2

Tools for managing Magento projects and installations

928244.3k6](/packages/n98-magerun2)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k5](/packages/elgg-elgg)[webfactory/slimdump

slimdump is a little tool to help you creating dumps of large MySQL-databases.

188124.8k1](/packages/webfactory-slimdump)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[worksome/foggy

Foggy is a tool for making database dumps with some data removed/changed.

26571.7k1](/packages/worksome-foggy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
