mongo-transporter

module
v0.0.0-...-d8c2046 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2018 License: BSD-3-Clause

README

This project is heavily outdated. I plan to get it working again at some point but for now it probably won't work...

Mongo Transporter

A simple Go app that uses the Compose Transporter to transfer data between two MongoDB deployments and keep them in sync.

What's it good for?

  • Keeping dev, staging and production DB's in sync.
  • Zero-downtime migrations from one deployment to another.

Deploy!

Deploy

Click the deploy button to launch a new app instance, add your config/environment variables in the Heroku dashboard and click "Deploy for Free". This will create a new Heroku app. Worker dynos do not scale automatically when deploying, you will need to scale manually to one worker dyno via the dashboard or the command line: heroku ps:scale worker=1 -a 'YOUR APP NAME'

For now, Mongo Transporter will only sync a single DB on a deployment so if a deployment has multiple DB's, you will have to run multiple app instances. To run a "continuous sync", you will need to use this with a MongoDB replica set, this is because a replica set includes the oplog.rs collection on the local DB. Transporter "tails" this collection to keep the two deployments in sync.

Golang on Heroku is not yet officially supported so use at your own risk. No longer true: https://blog.heroku.com/archives/2015/7/7/go_support_now_official_on_heroku Need to work on native support now and remove the buildpack

Config vars

  • SOURCE_MONGO_URL - This is the full connection URI of the MongoDB deployment that you want to sync from. eg. mongodb://username:strongpassword@candidate.33.mongolayer.com:30000,candidate.34.mongolayer.com:30000/local?authSource=prod_db You will need to create a user that can read from the local.oplog.rs namespace. You can use both members of the replica set.
  • SOURCE_DB - The DB name to sync from. eg. prod_db
  • SINK_MONGO_URL - This is the full connection URI of the MongoDB deployment that you want to sync to. eg. mongodb://username:strongpassword@candidate.43.mongolayer.com:30000,candidate.44.mongolayer.com:30000/staging_db The user does not need to authenticate to the local DB but needs read write access to SINK_DB. You can use both members of the replica set.
  • SINK_DB - The DB name to sync from. eg. staging_db
  • TAIL - Specify true to run a continuous sync, tailing the oplog. False for a one-time sync.
  • DEBUG - Specify true for verbose logging to stdout.

Run $ heroku logs -ta MY_APP_NAME from the command line to check out the logs.

What is does

  • Connect to both the source and the destination and finds the oplog timestamp
  • Copies all the collections in parallel
  • Tails the oplog from the initial timestamp, and applies the operations in a batch (ignoring a list of blacklisted commands - dropDatabase, etc). There is no conflict resolution with Transporter. When writing to the source and the destination, the last write always wins.

What it does not do

  • Copy DB users
  • Copy indexes

You will have to recreate any (non-unique) indexes and create new users on the destination DB, a small trade-off for the ease of use.

Thanks

The engineers at Compose for making an awesome tool, Transporter.

This app uses the Go Buildpack for Heroku by @kr

To Do

  • 2.4/2.6/3.0 caveats (if any)
  • Comma separated list of collections to ignore
  • Improve log output
  • Slack notifications

License

Copyright (c) 2014, Compose, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of [project] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Directories

Path Synopsis
Godeps
_workspace/src/code.google.com/p/goprotobuf/proto
Package proto converts data structures to and from the wire format of protocol buffers.
Package proto converts data structures to and from the wire format of protocol buffers.
_workspace/src/github.com/bitly/go-hostpool
A Go package to intelligently and flexibly pool among multiple hosts from your Go application.
A Go package to intelligently and flexibly pool among multiple hosts from your Go application.
_workspace/src/github.com/compose/transporter/pkg/message
Package message provides wrapper structs and helper methods to pipe actual database documents throughout transporter.
Package message provides wrapper structs and helper methods to pipe actual database documents throughout transporter.
_workspace/src/github.com/compose/transporter/pkg/pipe
Package pipe provides types to help manage transporter communication channels as well as event types.
Package pipe provides types to help manage transporter communication channels as well as event types.
_workspace/src/github.com/compose/transporter/pkg/transporter
Package transporter provides all adaptoremented functionality to move data through transporter.
Package transporter provides all adaptoremented functionality to move data through transporter.
_workspace/src/github.com/dancannon/gorethink
Go driver for RethinkDB Current version: v0.5.0 (RethinkDB v1.15.1) For more in depth information on how to use RethinkDB check out the API docs at http://rethinkdb.com/api
Go driver for RethinkDB Current version: v0.5.0 (RethinkDB v1.15.1) For more in depth information on how to use RethinkDB check out the API docs at http://rethinkdb.com/api
_workspace/src/github.com/dancannon/gorethink/ql2
Package ql2 is a generated protocol buffer package.
Package ql2 is a generated protocol buffer package.
_workspace/src/github.com/robertkrimen/otto
Package otto is a JavaScript parser and interpreter written natively in Go.
Package otto is a JavaScript parser and interpreter written natively in Go.
_workspace/src/github.com/robertkrimen/otto/ast
Package ast declares types representing a JavaScript AST.
Package ast declares types representing a JavaScript AST.
_workspace/src/github.com/robertkrimen/otto/dbg
Package dbg is a println/printf/log-debugging utility library.
Package dbg is a println/printf/log-debugging utility library.
_workspace/src/github.com/robertkrimen/otto/file
Package file encapsulates the file abstractions used by the ast & parser.
Package file encapsulates the file abstractions used by the ast & parser.
_workspace/src/github.com/robertkrimen/otto/parser
Package parser implements a parser for JavaScript.
Package parser implements a parser for JavaScript.
_workspace/src/github.com/robertkrimen/otto/registry
Package registry is an expirmental package to facillitate altering the otto runtime via import.
Package registry is an expirmental package to facillitate altering the otto runtime via import.
_workspace/src/github.com/robertkrimen/otto/terst
Package terst is a terse (terst = test + terse), easy-to-use testing library for Go.
Package terst is a terse (terst = test + terse), easy-to-use testing library for Go.
_workspace/src/github.com/robertkrimen/otto/token
Package token defines constants representing the lexical tokens of JavaScript (ECMA5).
Package token defines constants representing the lexical tokens of JavaScript (ECMA5).
_workspace/src/github.com/robertkrimen/otto/underscore
Package underscore contains the source for the JavaScript utility-belt library.
Package underscore contains the source for the JavaScript utility-belt library.
_workspace/src/gopkg.in/fatih/pool.v2
Package pool implements a pool of net.Conn interfaces to manage and reuse them.
Package pool implements a pool of net.Conn interfaces to manage and reuse them.
_workspace/src/gopkg.in/mgo.v2
Package mgo offers a rich MongoDB driver for Go.
Package mgo offers a rich MongoDB driver for Go.
_workspace/src/gopkg.in/mgo.v2/bson
Package bson is an implementation of the BSON specification for Go: http://bsonspec.org It was created as part of the mgo MongoDB driver for Go, but is standalone and may be used on its own without the driver.
Package bson is an implementation of the BSON specification for Go: http://bsonspec.org It was created as part of the mgo MongoDB driver for Go, but is standalone and may be used on its own without the driver.
_workspace/src/gopkg.in/mgo.v2/internal/scram
Pacakage scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
Pacakage scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
_workspace/src/gopkg.in/mgo.v2/txn
The txn package implements support for multi-document transactions.
The txn package implements support for multi-document transactions.
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL