There's a lot of open issues
A long-lived project that still receives updates
database-cloner-rails provides two rake tasks for moving database records between Rails environments. `rake database:download` dumps all ActiveRecord model records to plain Ruby files (Model.create(...) statements). `rake database:upload` replays those files to restore records in the target database. Useful for seeding a staging environment from production data, creating snapshots before destructive migrations, or sharing realistic test data across a team. Supports optional MODELS filtering: `rake database:download MODELS=users,posts` to dump only specific tables. The dump directory is created automatically.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.12
~> 1.7

Runtime

>= 5.0
 Project Readme

database-cloner-rails

A Rails gem that provides Rake tasks to back up and restore your database records across environments.

How it works

The gem iterates over all ActiveRecord models in your app, serializes their records to Ruby files, and can replay those files to restore the data. Useful for seeding a staging environment from production data or creating snapshots.

Installation

Add this line to your Gemfile:

gem 'database-cloner-rails'

Then run:

bundle install

Usage

Download (backup)

Dumps all records from every model into individual .rb files under lib/tasks/database_cloner/db_dump/:

rake database:download

Each file contains Model.create(...) calls — one per record — with id, created_at, and updated_at stripped out.

Upload (restore)

Replays the dumped files to recreate records in the current database:

rake database:upload

If a model's dump file fails to load, it prints a warning and continues with the rest.

Notes

  • Only models that can be resolved via classify.safe_constantize are included.
  • Records are ordered by id during the dump.
  • The db_dump/ directory must exist before running database:download.