Giter VIP home page Giter VIP logo

heroku-mongo-sync's Introduction

Heroku - Mongo Sync

This is a plugin for the Heroku command line, adding commands to sync your local and production mongo databases.

It was tested and should just work with Mongo HQ. If you host your mongo db somewhere else, just make sure you have access from your local machine.

Installation

$ heroku plugins:install http://github.com/marcofognog/heroku-mongo-sync

Config

The plugin assumes your local mongo db is running on your localhost with the standard settings (port 27017, no auth). It will use a database named after the current Heroku app name.

If you are using Mongoid, configuration will be read in mongoid.yml.

You can change any of these defining the URL it should connect to, like:

export MONGO_URL = mongodb://user:pass@localhost:1234/db

For production, it will fetch the MONGO_URL from the Heroku app config vars.

Usage

Get a copy of your production database with:

$ heroku mongo:pull
Replacing the myapp db at localhost with genesis.mongohq.com
Syncing users (4)... done
Syncing permissions (4)... done
Syncing plans (17)... done

Update your production database with:

$ heroku mongo:push
THIS WILL REPLACE ALL DATA FOR myapp ON genesis.mongohq.com WITH localhost
Are you sure? (y/n) y
Syncing users (4)... done
Syncing permissions (4)... done
Syncing plans (17)... done

As usual, in case you're not inside the app checkout you can specify the app you want to pull/push to:

$ heroku mongo:pull --app myapp-staging

If you're inside a checkout with multiple apps deployed, you can also specify the one to pull/push to by the git remote:

$ heroku mongo:pull --remote staging

Notes

Created by Pedro Belo. Support for indexes, users and more added by Ben Wyrosdick. Maintained by Marco Antonio

Use at your own risk.

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

heroku-mongo-sync's People

Contributors

benwyrosdick avatar dluxemburg avatar florentmorin avatar kaievns avatar ma11hew28 avatar marcofognog avatar rgabo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

heroku-mongo-sync's Issues

Error with mongo:pull

Thanks for writing such a handy heroku add-on!! Unfortunately I'm getting the following back trace when I try to use it. Any help is appreciated.

P.S. Don't worry about the data on the back trace, I've change them and are not the real values.

 !    DEPRECATED: Heroku::Client#deprecate is deprecated, please use the heroku-api gem.
 !    DEPRECATED: More information available at https://github.com/heroku/heroku.rb
 !    DEPRECATED: Deprecated method called from /usr/local/heroku/lib/heroku/client.rb:129.
Replacing the curioso-mvp db at mongodb://localhost:27017/curioso-mvp with mongodb://heroku_appefsdfwqe_A:[email protected]:29fdsafds0/heroku_app2fsdfsfds7
 !    DEPRECATED: Heroku::Client#deprecate is deprecated, please use the heroku-api gem.
 !    DEPRECATED: More information available at https://github.com/heroku/heroku.rb
 !    DEPRECATED: Deprecated method called from /usr/local/heroku/lib/heroku/client.rb:129.
 !    Heroku client internal error.
 !    Search for help at: https://help.heroku.com
 !    Or report a bug at: https://github.com/heroku/heroku/issues/new

    Error:       wrong number of arguments(2 for 1) (ArgumentError)
    Backtrace:   /var/lib/gems/1.9.1/gems/bson-1.10.2/lib/bson/bson_c.rb:24:in `deserialize'
                 /var/lib/gems/1.9.1/gems/bson-1.10.2/lib/bson/bson_c.rb:24:in `deserialize'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/networking.rb:236:in `read_documents'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/networking.rb:182:in `receive'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/networking.rb:144:in `receive_message'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/cursor.rb:543:in `block in send_initial_query'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/functional/logging.rb:55:in `block in instrument'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/functional/logging.rb:20:in `instrument'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/functional/logging.rb:54:in `instrument'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/cursor.rb:539:in `send_initial_query'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/cursor.rb:524:in `refresh'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/cursor.rb:136:in `next'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/db.rb:556:in `command'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/mongo_client.rb:547:in `block in check_is_master'
                 /usr/lib/ruby/1.9.1/timeout.rb:69:in `timeout'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/mongo_client.rb:546:in `check_is_master'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/mongo_client.rb:400:in `connect'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/mongo_client.rb:661:in `setup'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/mongo_client.rb:177:in `initialize'
                 /var/lib/gems/1.9.1/gems/mongo-1.10.2/lib/mongo/legacy.rb:52:in `initialize'
                 /home/tatsuhiro/.heroku/plugins/heroku-mongo-sync/lib/heroku/command/mongo.rb:115:in `new'
                 /home/tatsuhiro/.heroku/plugins/heroku-mongo-sync/lib/heroku/command/mongo.rb:115:in `make_connection'
                 /home/tatsuhiro/.heroku/plugins/heroku-mongo-sync/lib/heroku/command/mongo.rb:25:in `transfer'
                 /home/tatsuhiro/.heroku/plugins/heroku-mongo-sync/lib/heroku/command/mongo.rb:20:in `pull'
                 /usr/local/heroku/lib/heroku/command.rb:218:in `run'
                 /usr/local/heroku/lib/heroku/cli.rb:37:in `start'
                 /usr/bin/heroku:25:in `<main>'

    Command:     heroku mongo:pull
    Plugins:     heroku-mongo-sync
    Version:     heroku-toolbelt/3.9.7 (x86_64-linux) ruby/1.9.3

"Install the Mongo gem to use mongo commands"

I get the "Install the Mongo gem to use mongo commands" message even after I have installed the mongo gem.

> gem list mongo
*** LOCAL GEMS ***
mongo (1.10.2)

> heroku mongo:push
 !    Install the Mongo gem to use mongo commands:
 !    sudo gem install mongo

heroku-mongo-sync asks to install mongo gem even though it is already installed

c:\Users\folmert\node-js-getting-started>heroku mongo:push
! Install the Mongo gem to use mongo commands:
! sudo gem install mongo

c:\Users\folmert\node-js-getting-started>gem install mongo
Successfully installed mongo-2.0.1
Parsing documentation for mongo-2.0.1
Done installing documentation for mongo after 3 seconds
1 gem installed

c:\Users\folmert\node-js-getting-started>heroku mongo:push
! Install the Mongo gem to use mongo commands:
! sudo gem install mongo

Mongo connection failure

Hello, I am experiencing the following error after a first installation of the plugin.

Heroku client internal error.
uninitialized constant Mongo::ConnectionFailure

/Users/dragoon/.heroku/plugins/heroku-mongo-sync/lib/heroku/command/mongo.rb:106:in `rescue in make_connection'
/Users/dragoon/.heroku/plugins/heroku-mongo-sync/lib/heroku/command/mongo.rb:102:in `make_connection'
/Users/dragoon/.heroku/plugins/heroku-mongo-sync/lib/heroku/command/mongo.rb:28:in `transfer'
/Users/dragoon/.heroku/plugins/heroku-mongo-sync/lib/heroku/command/mongo.rb:22:in `pull'
/usr/local/Cellar/heroku-toolbelt/3.40.6/libexec/lib/heroku/command.rb:212:in `run'
/usr/local/Cellar/heroku-toolbelt/3.40.6/libexec/lib/heroku/cli.rb:27:in `start'
/usr/local/Cellar/heroku-toolbelt/3.40.6/libexec/bin/heroku:24:in `<main>'

Syncing system.indexes

I'm getting an error when I try to push to Heroku (with MongoLab).

"Database command 'insert' failed: not authorized on heroku_app32590136 to execute command { insert: "system.indexes", documents: [ { v: 1, key: { _id: 1 }, name: "_id_", ns: "heroku_app32590136.system.users", _id: ObjectId('5491d91ebaeecd4b93000001') } ], writeConcern: { w: 1 }, ordered: true } (Mongo::OperationFailure)"

I emailed MongoLab support and they said that increased restrictions on the system namespace in Mongo 2.6 are preventing inserting into the system.index collection. Instead, we should be using ensureIndex (see here: http://docs.mongodb.org/manual/reference/system-collections/).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.