Can you please help me on restoring the Indexes alone using mongorestore command,
I am using mongo restore command to restore data and Indexes, the data is restored successfully, but the Indexes are getting failed, Can any of you suggest on how to run the restoration command for only Indexes alone.
And here are the details:
mongorestore version: 100.8.0
Database version of Source and Target are 6.0.19.
Once the source of the index error is corrected then just restoring the indexes can be completed by having just the metadata files of the dump present in a dump directory.
Hi @Dinesh_Reddy_Sanikommu,
I did a test and it seems to me that the cause of this problem is due to trying to create an index of type unique on a field that has duplicate values after restoring documents.
@Fabio_Ramohitaj , What could be the possible ways of restoring the data and Indexes with out any failure? Can you please suggest me the steps, if any.
Hi @Dinesh_Reddy_Sanikommu,
Remove the unique indexes from the prod environment and recreate them normal So that in the next dump and restore it won’t give you problems for example , or manually create the indexes on the staging environment so that you do not have to touch the production environment. There are several ways.
Finally, I suggest that you investigate the problem some more because it does not seem at all obvious to me that my answer is absolutely correct.
The dump, and the source collection, contains the duplicate. I suggest running validate on the source collection, the linked documentation explains how to best run this.
Fix the duplicate. Either in the source and dump it again or in restored collection and then create the indexes.
The error log (please follow formatting guidlines) indicates what document is preventing the index build. Removing one(possibly more) of the conflicting documents will resolve this.