Giter Site home page Giter Site logo

migrate-mongo's Introduction

migrate-mongo

Build Status

Migrate mongodb collections by streaming way,include data and indexes.

Powered by MongoDB Go driver

Features

  • Migrate mongo all data from db to db
  • Migrate mongo data from db to db by specified collections
  • Migrate mongo data include indexes, create indexes before inserting data
  • Batch inserting for migration
  • Interval between each single inserting

Install

go get -u github.com/Dongss/migrate-mongo

Usage

$ migrate-mongo --help

A Tool for data migrations between mongodb databases.
Migrations are by streaming way.
Complete documentation is available at https://github.com/Dongss/migrate-mongo

Usage:
  migrate-mongo [command]

Available Commands:
  cln         Migrate specified collections
  help        Help about any command
  version     Print the version of migrate-mongo

Flags:
  -h, --help   help for migrate-mongo

Use "migrate-mongo [command] --help" for more information about a command.

Migration options:

$ migrate-mongo help cln

Migrate specified collections

Usage:
  migrate-mongo cln <collections> [flags]

Flags:
      --all            Migrate all collections
  -b, --batch int32    Batch insert, count of each inserting (default 1)
  -d, --dst string     Destination mongodb uri (required) (default "mongodb://user:[email protected]/database2")
  -h, --help           help for cln
      --index          Include indexes, create indexes before inserting data
  -i, --interval int   Interval of each single insert, milliseconds
      --show-only      Only show details of source db collection, no migration operation
  -s, --src string     Source mongodb uri (required) (default "mongodb://user:[email protected]/database1")

Example

Overview:

migrate-mongo cln test log --src mongodb://u:[email protected]:27017/db1 --dst mongodb://u:[email protected]:27017/db2 --show-only

outputs:

Collection details: [test log]

Name: test
Count: 4
Indexes:
   _id_, userid_-1

Name: log
Count: 1548
Indexes:
   _id_

Migrate:

migrate-mongo cln test test2 --src mongodb://u:[email protected]:27017/db1 --dst mongodb://u:[email protected]:27017/db2

outputs:

Collection details: [test test2]

Name: test
Count: 4
Indexes:
   _id_, userid_-1

Name: test2
Count: 3
Indexes:
   _id_

Start migration:

Done: test 4/4, elapsed: 159ms
Done: test2 3/3, elapsed: 112ms

Test

go test ./...

Tips

  • You should avoid db writing while migrating

LICENSE

LICENCE MIT

migrate-mongo's People

Contributors

dongss avatar

Stargazers

 avatar

Watchers

 avatar  avatar

migrate-mongo's Issues

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.