/db-snapshot

DB management tool for Mongoid

Primary LanguageRubyMIT LicenseMIT

Db::Snapshot

DB::Snapshot let's you programatically switch your MongoDB database to previous stages. This is useful when you need have one server/computer that is running Demos or supporting some kind of reverse process to clean the database and let it in the default version.

Ruby code in the file lib/db/snapshot. To experiment with that code, run bin/console for an interactive prompt.

Installation

Add this line to your application's Gemfile:

gem 'db-snapshot'

And then execute:

$ bundle

Or install it yourself as:

$ gem install db-snapshot

Usage

You have 3 useful methods with Db::Snapshot

list

Provides a list of the folders inside the dump/ folder.

create

Creates a snapshot of the existing database, it uses the following format for the snapshot name yyyymmdd_hhmm

# Optional, you can send your own name for this snapshot.
Db::Snapshot.create()

Result:

dump/20160612_2115/my_db_name

travel_to

Like a time machine, you can travel to the past with this method, this is how to use it:

Db::Snapshot.travel_to('20160612_2115')

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mcka1n/db-snapshot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

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