Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Adds a rake task to your Rails app to conveniently backup its database
Branch: master
Failed to load latest commit information.
lib updating plugin to work with Ruby 1.9
rails Initial commit
recipes adding a db:restore recipe
test Initial commit
MIT-LICENSE Initial commit Updating the readme file
Rakefile Initial commit

DB Backup

Adds a rake task to your Rails app to conveniently backup its database.
Only works with PostgreSQL at the moment.


script/plugin install git://



A backup will be created in ~/database_backups. A backup is stored in a plain text .sql file by default.

# create a backup (file extension '.sql')
rake db:backup

If you want to compress your backup - using PostgreSQL's custom dump format - do the following:

# create a compressed backup (file extension '.backup')
rake db:backup compress=true

If you have capified your application, you can also use the capistrano recipe to backup your remote databases.

cap db:backup [compress=true]

Note: the backups are stored on the remote server.


Currently, only .sql files are supported for restoring.
Restore from your backup file like this:

rake db:restore file=~/database_backups/mydb_production_20110429170000.sql

This will:

  1. Create a backup of the existing database,
  2. drop the existing database,
  3. re-create an empty database and
  4. restore the database structure and data from the file you specified.

There's a capistrano recipe for this task, too.

# the file paramater has to be a valid filepath on the server
cap db:backup file=~/mydb_production_20110429170000.sql


  • Support for more databases
  • Ability to overwrite the path where the backup is saved to
  • Ability to add additional custom description to file name


Inspiration taken from thoughbot's limerick_rake.

Copyright (c) 2011 Daniel Pietzsch, released under the MIT license

Something went wrong with that request. Please try again.