Hi Naveen
Is there some option in Export to JSON by mongoexport both files and chunks after time stamp
Generally unless you need a textual JSON representation of documents, it’s preferable to use mongodump and mongorestore instead, since those tools dumps/restores using MongoDB-native BSON format. This will make those dumps faster to create and faster to load.
To limit the dump to specific documents, mongodump supports the --query parameter.
Having said that, GridFS consists of two collections: fs.files and fs.chunks. While it is possible to query the fs.files collection for e.g. date created metadata, those same metadata is currently not available in the fs.chunks collection. So some manual coding would be required to determine which documents in the fs.chunks collection that are relevant.
Another possible solution is to prepare the fs.files and fs.chunks collections in your local deployment for exporting by removing unwanted files, so that you can do a simple mongodump operation without worrying about querying and manual intervention.
Best regards
Kevin
Hi Naveen,
what is difference between mongoexport/import and mongodump/restore
MongoDB uses BSON, which is a binary-encoded serialization of documents. One advantage of BSON compared to JSON is the existence of extended datatypes, which JSON doesn’t have.
mongoexport will output documents in JSON format. Similarly, mongoimport will import JSON documents into your MongoDB instance. These tools are needed for interoperability between JSON & BSON. Note that in both tools, the input/output format is text (structured as JSON). This necessitates a transformation between MongoDB-internal BSON format into text
In contrast, mongodump and mongorestore inputs & outputs BSON (binary). If your intent is to create a backup of your MongoDB instance, using those tools avoids the transformation step of mongoimport & mongoexport, thus the process is generally faster. Also note that both tools also dumps and restores indexes in the collection, which mongoimport & mongoexport doesn’t do.
Best regards,
Kevin