/capistrano-mongo-sync

capistrano task to sync your local development mongo database from production

Primary LanguageRubyOtherNOASSERTION

capistrano-mongo-sync

Use capistrano-mongo-sync to sync your local development database from your production database using:

cap production mongo:pull

Or sync just one collection from the database:

COLLECTION=users cap production mongo:pull

Or sync your staging database from your production database.

cap production mongo:sync_prod_to_staging

If you've already downloaded a mongo dump with the cap task, it will ask you if you'd like to use that local dump. If someone has already created a mongo dump recently on the remote server, the cap task will ask if you'd like to use that dump. Older mongodumps, both remote and local, will be deleted when you run the cap task.

Usage

Add to your Gemfile:

gem 'capistrano-mongo-sync'

Require in Capfile to use the predefined tasks:

require 'capistrano/mongo-sync'

In deploy.rb, set some variables:

set :production_db, 'PRODUCTION_DB'
set :development_db, 'DEVELOPMENT_DB'

set some optional variables:

set :staging_db, 'STAGING_DB'

enable hipchat notifications (requires hipchat gem):

set :hipchat_client, HipChat::Client.new('HIPCHAT_TOKEN')

change where mongodumps are kept remotely and locally:

set :remote_dump_base, '/tmp/dumps'
set :local_dump_base, '/tmp/dumps'

Or write your own tasks using the MongoSync class