I have two MongoDB clusters: DEV and PRO. For backup purposes, I use mongodump
to export each and every database from the PRO cluster, including users, indexes, and roles:
mongodump --host "<PRO_CLUSTER>" --dumpDbUsersAndRoles ...
When I restore the database example1
from the PRO cluster into the DEV cluster, everything works as expected: all collections, documents, users, and indexes are restored correctly.
mongorestore -d example1 --restoreDbUsersAndRoles --host "<DEV_CLUSTER>" backup_pro_example1.tar.gz
However, if I try to restore the backup under a different database name, e.g: example2
, while collections and documents are restored correctly, users and indexes are missing.
mongorestore -d example2 --restoreDbUsersAndRoles --host "<DEV_CLUSTER>" backup_pro_example1.tar.gz
How can I work around this issue to ensure users and indexes are also restored when restoring to a different database name?