I would like to know if there is a solution to replicate indexes from on cluster to another without erasing data ?
I have 2 clusters: production and staging, in 2 different project.
The 2 db inside each cluster have the same schema.
There is multiple indexes in the staging db that I would like to replicate into the production db without erasing any data in the collections (so no restore I think)
Is it Possible ?
Can it be automated ?
We use MongoDB Atlas Serverless for the 2 clusters
We use nodejs 16 mongodb driver v4.12.1
While I do not have specific details to give, I am confident that you will find what you wish in
An alternative way will be with a simple JS script that looks like:
staging = MongoClient( ... )
production = MongoClient( ... )
for db_to_replicate in all databases to replicate indexes
{
db = staging.db( db_to_replicate )
for collection_to_replicate in all collections of db
{
collection = db.collection( collection_to_replicate )
for index in collection.listIndexes()
{
production.db( db_to_replicate ).collection( collection_to_replicate ).createIndex( index )
}
}
}