git friendly dumper

Use fixtures to create a db independent and git friendly db dump.

It’s git friendly because each record is in its own file (git doesn’t do very well with large files that are committed all at once).

If using the schema option (ie. db:dump & db:load), then each table’s schema definition is included as is the schema_migrations table.

Example usage:

# drop-in replacement for mysqldump

rake db:dump DUMP_PATH=some/path
# just like mysqldump -u <user> -p<pass> <app>_development > some/path.sql

rake db:load DUMP_PATH=some/path
# just like script/dbconsole -p < some/path.sql

# without schema information, just the data

rake db:data:dump DUMP_PATH=some/path # dump the data without touching the structure
rake db:data:load DUMP_PATH=some/path # load the data without touching the structure

# just load particular table data
rake db:data:load DUMP_PATH=some/path TABLES=users,things

See ‘lib/tasks/git_friendly_dumper_tasks.rake` and the features for more info

Notes

It’s probably a bad idea to check your dump into the same repo as your app.

I created this so that we could have incremental scheduled backups of the db. With a database of 120M containing many binary columns, this resulted in a massive saving in bandwidth.

Basically, we have the db backup inside the app, but ignored by the main app, the db/dump has it’s own git repo.

Run the specs and features

Grab the last known good set of deps and run the specs and features

cp Gemfile.lock.development Gemfile.lock
bundle
rake