MongoDB index copy
A utility to copy indexes from one database to another.
Run the python utility and capture its output.
python mongoindexcopy.py > index_creation_script.js
The example above creates a file index_creation_script.js
You can set the following:
||A full Mongo connection URL, including db name|
||A set of collection names to include in the script|
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.
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 = ("*")