-
Notifications
You must be signed in to change notification settings - Fork 97
MongoDB Export and Import
prohaska edited this page Apr 15, 2013
·
1 revision
- Export a collection to a JSON coded file.
- Runs a query on the collection to retrieve the documents.
- Can include query document from the command line to select documents.
- MongoDB optimizes the index selection.
- Import JSON coded documents from a file to a collection.
- Optionally drop the collection.
- Can insert or update the documents.
- Each insert or update is a separate operation.
- Duplicate key errors are ignored. The import code does not call getLastError after inserts, and does not ever call getPrevError.
- Duplicate key errors are ignored even when stopOnError is set.
- Running with dbpath causes the mongoimport process to do the import directly to the database files.
- If mongoimport dbpath finds the env locked, it complains (good) but exits with a 0 exit code (bad).
- Located in jstests/tools/exportimport*.js.
- ToolTest requires /data/db for some reason.
- Make mongoimport transactional. All or no documents are imported.
- Make mongoimport check for errors, including duplicate key errors.
- Errors should cause mongoimport to exit with a non-zero exit code.
- For example, mongoimport with a locked data directory should exit with a non-zero exit code.