Search code examples
ruby-on-railscapistranoproductionstaging

copy production database to staging capistrano


I am using rails and capistrano with a staging and production server. I need to be able to copy the production database to the staging database when I deploy to staging. Is there an easy way to accomplish this?

I thought about doing this with mysql and something like:

before "deploy:migrate" do
  run "mysqldump -u root #{application}_production > output.sql"
  run "mysql -u root #{application}_staging < output.sql"
end

(I have not tested this btw, so not sure it would even work) but it would be easier / better if there was another way.

Thanks for any help


Solution

  • I do this -- it is really useful. Here are links explaining how ...

    http://c.kat.pe/post/capistrano-task-for-loading-production-data-into-your-development-database/

    or

    http://blog.robseaman.com/2008/12/2/production-data-to-development

    or

    https://web.archive.org/web/20160404204752/http://blog.robseaman.com/2008/12/2/production-data-to-development