Mongodb – Failed to import a mongodb database with duplicate fields

mongodbmongodb-3.6mongodb2.4mongodumpmongorestore

I'm trying to import a mongodb database and I've been using the mongorestore command, the import starts without problems until it gives the error:
Failed: dbprod.mys_account: error creating collection dbprod.mys_account: error running create command: BSON field 'OperationSessionInfo.create' is a duplicate field

I already tried the option –drop but without success, I had never worked with mongodb … I must clarify that I saved it in a mongodb 2.4 with mongodump and I try to import for a mongodb 3.6

Best Answer

I have successfully upgraded a database from 2.4 to 4.0 using the following 3 step method:

  1. use 2.4 mongobackup on the 2.4 database
  2. delete all .json files from the outputted dump directory
  3. use 4.0 mongorestore on the remaining .bson files