Dump and restore databases easily.
Backup and Restoration Strategies & MongoDB Manual
Add this line to your application's Gemfile:
gem 'mongodb_clone'
And then execute:
$ bundle
Use a rake task to dump production database and restore locally.
$ rake db:copy:production:to_local
or create your tasks:
# Dump environment "staging", session "default" and restore in "development" environment, session "backup"
MongodbClone::MongodbReplication.new.dump('staging').restore('development', 'backup')
Use config/mongoid.yml
to configure the environments:
development:
sessions:
default:
database: mongodb_clone_development
hosts:
- localhost:27017
backup:
database: mongodb_clone_development
hosts:
- localhost:27017
staging:
sessions:
default:
database: mongodb_clone_staging
username: mongodb_clone
password: 12345678
hosts:
- mongodb_clone_staging.example.com:27017
production:
sessions:
default:
database: mongodb_clone_production
username: mongodb_clone
password: 12345678
hosts:
- mongodb_clone.example.com:27017
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
MIT License. Copyright 2012 Tiago Rafael Godinho