We have a process of working with mongodb dumps. The flow is as follows:
Make a dump on production DB using the following command: mongodump --uri ${DB_URI} --gzip --archive="${archive}"
Make a restore on dev DB using the following command: mongorestore --uri ${mongo.uri} --drop --gzip --archive="$dumpPath" --nsInclude="${mongo.sourceDatabase}.${mongo.sourceCollection}" --nsFrom="${mongo.sourceDatabase}.${mongo.sourceCollection}" --nsTo="${mongo.targetDatabase}.${mongo.targetCollection}
Both DBs have the same 4.2.5 version
Everything works great, except the fact that Date data type gets converted into String data type (at least this is what we see exploring the collection items) + Date format is changed from Instant (2019-06-15 11:45:58.364Z) to something having the time zone (2019-06-15T11:45:58.364+00:00)
Apologies for the late reply. Are you still having this issue? Out of curiosity, I tried replicating your procedure using the same MongoDB version but didn’t seem to have this issue. Both mongodump and mongorestore are not trying to do anything fancy and just dump the raw BSON data. They do not tamper with the data at all, so it’s curious how you can get the wrong type restored.
If this is still an issue, the output of mongodump --version and mongorestore --version might be useful. Also, are you certain that there is no app touching the collection after restore?