Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 1.35 KB

README.markdown

File metadata and controls

56 lines (40 loc) · 1.35 KB

What is it?

A simple script that splits a MySQL dump into lots of smaller files. It works both with data definitions and data only dumps.

Usage:

First you need a mysqldump file, put it into the directory you want all the split files in:

$ ruby split-mysql-dump.rb db.sql
Found a new db: app
Found a new table: administrator_log
    writing line: 229 200.494MB in 4 seconds 50.124MB/sec

    Found a new table: auth_strings
        writing line: 239 205.482MB in 6 seconds 34.247MB/sec

Alternatively, you can pipe in via STDIN in using '-s'. Great for working with large gzipped backups:

$ gunzip -c db.sql.gz | ruby split-mysql-dump.rb -s

You can also limit the dump to particular tables using '-t' or exclude tables using '-i'.

$ ruby split-mysql-dump.rb -t auth_strings, administrator_log db.sql

and

$ ruby split-mysql-dump.rb -i auth_strings

When you're done you should have lots of files like this:

-rw-r--r-- 1 rip rip   210233252 May 17 18:06 app_administrator_log.sql
-rw-r--r-- 1 rip rip   215463582 May 17 18:06 app_auth_strings.sql

The first bit of the files will be the database that the tables are in based on the USE statements in the dump.

Contact:

You can contact me on [email protected] or follow my blog at http://www.devco.net I am also on twitter as ripienaar