Skip to content

Dump and recreate data

slhck edited this page Jul 13, 2012 · 1 revision

If you want to export and re-import the data from one to another server, make sure that the yaml_db gem is installed as already included in the Gemfile:

gem 'yaml_db', :git => "git://github.com/lostapathy/yaml_db.git"

yaml_db allows you to export the data from a Rails application's environment — e.g. production — by cding to the project folder and calling the following command:

RAILS_ENV='production' rake db:data:dump

Your file should be called data.yml. It will be created in the db directory. Copy this data file to the new server, change to the db directory and call:

RAILS_ENV='production' rake db:data:load

The database should be migrated to the new server.