LoginSignup
14
14

More than 5 years have passed since last update.

RailsでproductionからDBコピー

Last updated at Posted at 2014-11-11

productionやstagingのDBからデータをコピーしたい時、yaml_dbなどありますが、ちょっとパフォーマンスが悪いです。

そこで、mysqldumpを使ってDBをダンプし、emailなどのprivacy情報を潰すcapistranoタスクを作りました。

使い方は簡単。Gemfilegem "capistrano-db-mirror"などとして、

Capfileに以下を追加。

require "capistrano/db-mirror"
cap staging db:mirror

とするだけ!

mysqldumpによりdumpしたファイルをダウンロードして、ローカルでロードします。
念のため、./dumpに1つ前のデータが残っており、

rake db:mirror:rollback

でロールバックできます。

※使用に関しては自己責任でお願いします。

14
14
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14