This is a rake task that dumps your entire database to a .sql file for your Rails environment.
Copy the file db.rake into {rails project}/lib/tasks directory.
rake db:dump
RAILS_ENV=production rake db:dump
Creates a file called dump-env-YYYY-MM-DD.sql, where env is typically development, production, or test.
This works as advertised in Rails 3.2, and likely works in many other versions.
Only works with mysql.