Download the PHP package ashleyhindle/private-dump without Composer
On this page you can find all versions of the php package ashleyhindle/private-dump. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ashleyhindle/private-dump
More information about ashleyhindle/private-dump
Files in ashleyhindle/private-dump
Package private-dump
Short Description CLI script to dump your MySQL database, and sanitise the output of sensitive data for development/staging use
License MIT
Informations about the package 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.
Private Dump requires PHP >= 7.3
Table of Contents
- Installation
- Usage
- Configuration File
- Key Value Tables
- Replacements
- Text
- Dates
- Internet
- Random
- User
- Payment
- Company
- Miscellaneous
- Barcodes
- Transformers
- Notes
- Dev Steps
- Release Process
Installation
Install with Composer
Install with curl
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 example config, 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:
Curl:
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
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 directory.
Annotated Example Configuration - private-dump.json
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:
This is a bit more complicated than the standard replacements, but offers a lot of flexibility for anonymising all types of data.
Replacements
The vast majority of these are made possible by the amazing Faker library. Most formatters listed in Faker's documentation are supported in Private Dump's configuration file
All replacements below should be prefixed with an @
as in the example configuration files.
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
original
- The original value, useful to use with modifiersstring
- Random length string up to 255 charactersrealText
- Quotes from booksloremSentence
- 1 sentence of LoremloremParagraph
- 3 sentences of LoremloremParagraphs
- 3 paragraphs of Lorem
Dates
iso8601
- 2019-01-20iso8601Recent
- ISO 8601 date in the last 3 months
Internet
email
- [email protected]url
- https://www.parliament.uk/bigbenipv4
ipv6
userAgent
domainName
- bigben.netslug
- big-ben-bing-bong
Random
randomDigit
- singular digitrandomNumber
- up to 8 digitsrandomLetter
randomString
- Random length string up to 255 characters
User
firstName
lastName
title
- Ms. Mr. Dr.fullName
- Brian MayfullAddress
- One line: Building number, street, city, state/county, postcode/zipbuildingNumber
- 368streetName
- BroadwaystreetAddress
- 368 Broadwaycity
- Londonpostcode
- SW1A 0AAcountry
- Englandstate
- Texascounty
- Londonlatitude
- 51.5008longitude
--.1246
phoneNumber
email
- [email protected]username
- BigBenpassword
url
- https://www.parliament.uk/bigbenipv4
- IPv4 Addressipv6
- IPv6 Address
Payment
creditCardType
- MastercardcreditCardNumber
- 4444 1111 2222 3333creditCardExpirationDate
- 04/22creditCardExpirationDateString
- '04/13'iban
- BI6B3N8497112740YZ575DJ28BP4swiftBicNumber
- BIGBEN22263
Company
company
- Company-NamejobTitle
- Croupier
Miscellaneous
boolean
md5
sha1
sha256
countryCode
- UKcurrencyCode
- EUR
Barcodes
barcodeEan13
barcodeEan8
barcodeIsbn13
barcodeIsbn10
Transformers
uppercase
lowercase
These notes are mainly for my own development use, feel free to ignore.
Dev Steps
- Install Box
- Modify PHP configuration to set
phar.readonly = Off
box build
chmod a+x bin/private-dump.phar
Release Process
- Build the PHAR:
box build
- Rename the PHAR:
mv bin/private-dump.phar ./private-dump
- Update the version in
README.md
's installation instructions based on the next version fromgit tag --list
- Tag the next release:
git tag -a vx.x.x -m "Release x.x.x"
- Push:
git push origin --tags
- Edit release on GitHub attaching the newly created
bin/private-dump
file
All versions of private-dump with dependencies
ext-json Version *
nategood/commando Version ^0.3.0
ifsnop/mysqldump-php Version ^2.9
fakerphp/faker Version ^1.14.0
dflydev/dot-access-data Version ^1.0
pelmered/fake-car Version ^1.6