mongograte
v2.4.0
Published
Tool for migrating MongoDB to MongoDB
Downloads
28
Readme
mongograte
A robust tool for seamless migration of data between MongoDB databases, allowing for efficient synchronization, with support for listening to live changes in the source database.
- :notebook_with_decorative_cover: Description
- :warning: Before running
- :hammer: Installation
- :writing_hand: Usage
- :bookmark_tabs: Options
- :monocle_face: Examples
- :page_with_curl: License
- :heart: Contribution
# Description
mongograte is a command-line tool designed to facilitate the migration of MongoDB collections and databases from a source server to a target server. It supports options for clearing existing data, limiting the number of documents to migrate, and listening to changes for real-time synchronization.
# Before Running
N/A
# Installation
npm i -g mongograte
# Usage
Basic usage example:
mongograte -d myDatabases -s mongodb://host:port -t mongodb://host:portYou can see default values in options section
# Options
The following command-line options are supported:
| Option | Description | Type | Required | Default value |
|-----------------|---------------------------------------------------------------|---------------|------------|----------------|
| -d, --databases | List of target databases to migrate | array | Yes | - |
| -s, --source | Source MongoDB server URI | string | Yes | - |
| -t, --target | Target MongoDB server URI | string | Yes | - |
| --migrate-collections | Collections to migrate from the source database | string | No | - |
| --ignore-collections | Collections to exclude from the migration process | string | No | - |
| --drop | Drop target collections in the target database before migration | boolean | No | false |
| --drop-all | Drop all collections in the target database before migration | boolean | No | false |
| --truncate | Truncate target collections in the target database before migration | boolean | No | true |
| -l, --limit | Maximum number of records to migrate per collection | number | No | 1000 |
| --query-limit | Maximum number of records per query | number | No | 1000 |
| --timeout | Timeout for MongoDB connection (ms) | number | No | 5000 |
| --listen | Enable real-time synchronization of source database changes | boolean | No | false |
| -i, --insecure | Allow using a remote database as the target | boolean | No | false |
| --skip-update | Skip checking for updates | boolean | No | false |
| -v, --version | Show version number | boolean | No | - |
| -h, --help | Display help information | boolean | No | - |
# Examples
Migrating a Database with Specific Options
To migrate the testDB from a local server to a remote server with the collection drop option enabled and a limit of 500 records, use:
mongograte -d testDB -s mongodb://localhost:port -t mongodb://remotehost:port --drop -l 500Real-Time Synchronization
To listen for changes in the source database and apply them to the target, use the --listen flag:
mongograte -d myDatabase -s mongodb://host:port -t mongodb://host:port --listenThis will keep your target database in sync with the source in near real-time.
# License
Distributed under the MIT License. See LICENSE for more information.
# Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a pull request
:star: Feel free to contribute :star:
