Skip to content

plusn-nuri/mongoindexcopy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MongoDB index copy

A utility to copy indexes from one database to another.

Usage

Run the python utility and capture its output.

The utility generates a JavaScript script which can be run from the MongoDB shell mongo.

python mongoindexcopy.py > index_creation_script.js

The example above creates a file index_creation_script.js

Configuration

You can set the following:

Setting Description
source_connection A full Mongo connection URL, including db name
include_collections A set of collection names to include in the script

Source Connection

The connection string for the source database you want to copy from. Note that the database name is part of the URL. The script uses that database name and only lists collections in that database.

Include Collections

A set of collection names to include. Using an asterisk * anywhere in the list will cause the script to include all collections in the database.

This is a white-list. Any collection not mentioned in this list will be skipped. Collection names are case sensitive (as are MongoDB's collection names).

Example: Script all collections in the database db1 on the server myserver1.

source_connection = "mongodb://myserver1/db1"
include_collections = ("*")

About

A utility to copy indexes from one DB to another, by generating an index creation script.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages