Skip to content

Export Collection at the DB Level for Testing (database dump for a collection)

Sara Brumfield edited this page Apr 29, 2026 · 1 revision

We have a rake task that will export all of a collection so it can be loaded locally for testing:

RAILS_ENV='production' bundle exec rake 'fromthepage:export:database_dump[jeremiah-white-graves-diaries]'

It puts a directory of yml files in ~/deployment/current/tmp/dumps

tar and gzip up the files:

tar cvf stendahl2.tar 1777473383
gzip stendahl2.tar

scp it to your test machine.

This uses the database that is specified for development to load the database dump into. You may want to create a new DB to load it into rather than overwriting your existing test data.

mysql --user=root --password

create database stendahl; grant all on stendahl.* to 'rails'@'%'; grant all on stendahl.* to 'rails'@'localhost';

RAILS_ENV=development rake db:create RAILS_ENV=development rake db:migrate

Then import using: RAILS_ENV='development' rake fromthepage:import:database_dump[path_to_dump]

Clone this wiki locally