Hi,

I am having a similar issue trying to automate a backup/restore procedure. I was doing several tests and on one occasion I backed up the database, then manually deleted the database and afterwards restored the backup. In this case only the custom indexes were not restored, even though the version of the database that I backed up did include the custom indexes. Only the default index was restored.
If I do the same procedure with the --drop option on mongorestore, the custom indexes are restored.
This is not to discuss the opportunity of manually deleting a database :smiley: but accidents happen, so I would expect that all the metadata is backed up and restored, that includes custom indexes.
The following are the commands I am using for backup/restore:

  • mongodump --uri=‘{uri}’
    –username=‘{accessKeyId}’
    –password=‘{secretAccessKey}’
    –awsSessionToken=‘{sessionToken}’
    –db=‘{database}’
    –gzip
    -vvv

  • mongorestore --uri=‘{uri}’
    –username=‘{accessKeyId}’
    –password=‘{secretAccessKey}’
    –awsSessionToken=‘{sessionToken}’
    –db=‘{database}’
    –drop
    –gzip
    ./dump
    -vvv
    So I have several questions

  • not saving/restoring custom indexes when the database is manually deleted is by design or is it a missed corner case?

  • how is this possible? Are the custom indexes linked somehow to the pre-existence of the database? or are the mongodump/mongorestore commands perform some inner logic on the custom indexes specifically?

Thank you