Project

db-clone

0.01
No release in over 3 years
Low commit activity in last 3 years
rake db:clone[manual] provides a CLI for selecting a specific source database to copy to a specific destination database. Supports postgreql and mysql.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 0.8
~> 10.0
~> 3.0

Runtime

~> 1.2.1
 Project Readme

Gem Version Build Status Coverage Status

db-clone

The db-clone gem provides a rake task for cloning one database into another. It does this by making a system call to mysqldump or pg_dump (currently only mysql and postgresql are supported) and uses the contents of your application's database.yml to determine the command line arguments.

Screenshot

Screenshot

Requirements

Ruby >= 2.3

db-clone requires mysqldump (for MySQL) and/or pg_dump (for PostgreSQL).

Installation

Add gem 'db-clone', '~> 2.1' to your Gemfile and bundle install.

Usage

To clone your production database to development, run:

rake db:clone

If you have more database blocks (besides production and development) defined in config/database.yml, you can clone between these databases using DbClone's CLI:

rake db:clone[manual]

Configuration

By default rake db:clone will read from config/database.yml and use your production database as the source and development as the destination. You can configure these defaults to something else by adding to your Rakefile (or in an initializer if you're using Rails):

Db::Clone.setup do |config|
  # default is 'config/database.yml'
  config.database_yml_path = '/path/to/my_database_config.yml'

  # default is 'production'
  config.default_source_database = 'my_source_db'

  # default is 'development'
  config.default_destination_database = 'my_destination_db'

  # default is [], adds --ignore-table arguments to mysqldump or --exclude-table arguments to pg_dump
  config.ignore_tables = ['schema_migrations', 'some_other_table']
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/seanhuber/db-clone.

License

The gem is available as open source under the terms of the MIT License.