( IMPORTANT DISCLAIMER . MUST configure database.yml correctly for this to work. I am not responsible for any data that you lost as a result of running the script below.)
For Ruby on Rails users, you can consider the Rake task like these db: clone tasks below.
I use this script constantly to clone from production to development. This is easier than remembering the mysqldump syntax, and even more so all the usernames and passwords ...
Clone from production to development:
rake db:clone:production
Clone from stage to development:
rake db:clone:staging
To clone from production to production:
rake db:clone:production_to_staging
And here you will like the code (and be careful when setting up your .yml database):
namespace :db do namespace :clone do class << self %w(development test staging production).each do |env| define_method("
source share