Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 6ccc2bd8ca
Fetching contributors…

Cannot retrieve contributors at this time

51 lines (35 sloc) 1.915 kB
Rake tasks to dump and import various database batch files. (currently only MySQL, but feel free to add additional)
Description: Dump database file and gzip for RAILS_ENV. Initial path of dump is to "db/". Set alternate path with INITIAL_PATH=path/to/dump/. To skip gzip use GZIP=no.
INITIAL_PATH=/my/db/dump/path/ (defaults to db/)
GZIP=yes|no (defaults to yes)
RAILS_ENV=production|development|test (default is development)
rake db:dump
- dumps development database to file in db/ folder
- then gzips the file so you're left with "env_database_name_dump.sql.gz"
rake db:dump INITIAL_PATH=.
- same as above except dumps into root of your application instead of db/
rake db:dump GZIP=no RAILS_ENV=production
- dumps production database to sql file in db/ folder
- does not gzip the file
db:import (or db:imp)
Description: Import database dump file into the specified RAILS_ENV. Select file with FILE=path/to/file. If the file is gzipped, it will be unzipped, imported and then gzipped back again.
RAILS_ENV=production|development|test - the environment database that the dump file is loaded into (defaults to development)
rake db:import FILE=db/development_db_name_dump.sql.gz RAILS_ENV=production
- first gunzips "development_db_name_dump.sql.gz"
- then imports sql file into "production_db_name" database
- finally gzips the file back up for the next usage
rake db:import FILE=db/development_db_name_dump.sql RAILS_ENV=test
- imports sql file into "test_db_name" database
- no gunzip or gzip takes place unless given a .gz file
Copyright (c) 2008 Elijah Miller / David Baldwin, released under the MIT license
Jump to Line
Something went wrong with that request. Please try again.