• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    Go
  • License
    Other
  • Created almost 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generate partial and filtered dumps of MySQL databases

MySQL Super Dump

Build Status Go Report Card

MySQL Super Dump is a tool to efficiently create filtered and manipulated database dumps. It relies in the power of the SQL native language to do this, using WHERE clauses and complete SELECT statements with aliases to do this.

Currently it does not support every kind of MySQL structure (views, triggers, etc), but it supports the most basic stuff: schemas, tables and rows.

History

Once uppon a time there was a development team that liked to use dumps from the production database in their development environments to have the same content and behavior of the production system in their machines.

To avoid security problems, the system administrator created a script to dump the production database, import in a temporary database, then replace all sensitive data, like salts, passwords, customer names, emails, etc, for fake data, then export a dump of this temporary database to a file that is the dump developers would use.

However this script was taking more time to run, day by day, and each day it was using more resources from the server to run, until it exploded.

Features

  • Filter dumped rows by a native WHERE clause ([where] config's section)
  • Replace dumped data with native SELECT functions ([select] config's section)
  • Disable data output of specific tables ([filter] config's section: nodata)
  • Ignore entire tables ([filter] config's section: ignore)

Usage

  • Install the latest Go compiler installed (check instructions at: http://golang.org)
  • Check you environment with go env:
  • The repository will be clones at $GOPATH/src/github.com/hgfischer/mysqlsuperdump
  • The binary will be installed in $GOBIN
  • Then run go get to download, build and install mysqlsuperdump: go get github.com/hgfischer/mysqlsuperdump
  • Create a config file based on example.cfg and place where you like it.
  • Run mysqlsuperdump -h to see command line options and voilΓ‘.

Configuration Example


[mysql]
# See https://github.com/Go-SQL-Driver/MySQL for details on this
dsn = username:password@protocol(address)/dbname?charset=utf8
extended_insert_rows = 1000
#use_table_lock = true
max_open_conns = 50

# Use this to restrict exported data. These are optional
[where]
sales_order           = created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
customer_upload       = created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)
newsletter_subscriber = created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY)

# Use this to override value returned from tables. These are optional
[select]
system_user.salt = 'reset salt of all system users'
system_user.password = 'reset password of all system users'

customer.first_name = CONCAT('Charlie ', id)
customer.last_name = 'Last'
customer.salt = 'reset salt of all customers'
customer.password = 'reset password of all customers'
customer.username = CONCAT(id, '@fiction.tld')
customer.username_canonical = CONCAT(id, '@fiction.tld')
customer.email = CONCAT(id, '@fiction.tld')
customer.email_canonical = CONCAT(id, '@fiction.tld')

newsletter_subscriber.email = CONCAT(id, '@fiction.tld')

customer_address.recipient_name = CONCAT('Recipient Name ', id)
customer_address.company = CONCAT('Company Name ', id)
customer_address.phone = CONCAT('(', id, ') 1234-1234')

sales_order_address.recipient_name = CONCAT('Recipient Name ', id)
sales_order_address.company = CONCAT('Company Name ', id)
sales_order_address.phone = CONCAT('(', id, ') 1234-1234')

system_dump_version.created_at = NOW()

# Use this to filter entire table (ignore) or data only (nodata)
[filter]
customer_stats = nodata
customer_private = ignore

TO DO

  • Extend MySQL support, with other objects like views, triggers, etc
  • Refactor dumper interface to support another SQL databases
  • Add support for PostgreSQL

License

Please, check the LICENSE file.

More Repositories

1

go-otp

Package go-otp implements one-time-password generators used in 2-factor authentication systems like RSA-tokens. Currently this supports both HOTP (RFC-4226), TOTP (RFC-6238) and Base32 encoding (RFC-3548) for Google Authenticator compatibility
Go
203
star
2

gomk

An opinionated Makefile for Go projects.
Makefile
95
star
3

domainerator

Simple application written in Go that combines two wordlists and a list of TLDs to form domain names and check if they are already registered.
Go
27
star
4

http-here

http-here is a simple http server for testing, local development, and learning.
Go
13
star
5

go-type-assertion-benchmark

Naive performance test of two ways to do type assertion in Go.
Go
6
star
6

nginx2stathat

Program to watch a nginx combined access.log and send every line to syslog
Go
5
star
7

go-iter

Idiomatic Go Iterators
Go
4
star
8

sns2slack

Simple HTTP server that listens for AWS SNS messages and reposts them to a SlackHD webhook.
Go
4
star
9

martini-vs-negroni

simple benchmark for comparing martini vs negroni
Go
4
star
10

go-bfmt

Conditional `fmt`
Go
3
star
11

setuid

test
Go
2
star
12

vim

My personal vim setup
Vim Script
2
star
13

go-zahlen

Converts natural numbers to it's full written form in German
Go
2
star
14

hgfischer.github.io-src

Hugo source of my personal website
CSS
1
star
15

shiny-sniffle

TypeScript
1
star
16

bootstrap

Makefile
1
star
17

talks

Go talks
Makefile
1
star
18

goat

Go
1
star
19

dnshaka

Go
1
star
20

golego

Nothing special here...
Go
1
star
21

textable

nothing to see here yet. come back soon.
Go
1
star
22

go-ackermann

Ackermann function in Go
Go
1
star
23

hgfischer.github.io

My personal website
HTML
1
star
24

wp_two_factor_radius_auth

Two-Factor RADIUS authentication plugin for Wordpress
PHP
1
star
25

elastictool

nothing to see here
Go
1
star
26

localkube

Local Kubernetes Cluster with libvirt and Vagrant
Makefile
1
star
27

rlm_perl_hotp

HOTP/RFC-4226 authentication script for FreeRadius that uses Redis as user token's database
Perl
1
star
28

go-lokia

Go
1
star
29

Kubernetes14

Shell
1
star
30

gocql-debug

Debugging gocql
Shell
1
star