The documentation for mongoexport
has this scary warning,
Avoid using mongoimport and mongoexport for full instance production backups. They do not reliably preserve all rich BSON data types, because JSON can only represent a subset of the types supported by BSON. Use mongodump and mongorestore as described in MongoDB Backup Methods for this kind of functionality.
The page then goes on to say,
To preserve type information, mongoexport and mongoimport uses the strict mode representation for certain types.
What exactly are the types that mongoexport still doesn't represent properly, in spite of the "strict mode representation"?
Asking because mongorestore
has an extremely annoying limitation: it doesn't support an upsert
option, which makes it impossible to use for synchronizing collections where only a few documents get updated. You'd have to --drop
the whole collection before restoring it entirely from scratch, which can be very time consuming for large collections, especially if text indexes need to be recreated.