Mongodump / Mongorestore Changes Date Type to String

Hi all,

We have a process of working with mongodb dumps. The flow is as follows:

  1. Make a dump on production DB using the following command:
    mongodump --uri ${DB_URI} --gzip --archive="${archive}"
  2. 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)

Hi @Vladyslav_Baidak,

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?

Best regards,

1 Like

Hi @kevinadi ,
Thanks for your reply.

I’ve check this one more time and it seems that the issue is on our side, not related to mongodump / mongorestore.

So I think we can close the ticket