mongodb-restore
mongodb-restore copied to clipboard
Restoring from BSON dump breaks when directory contains metadata files created by mongodump
By default recent versions of mongodump create metadata files in the form of
I suggest checking for !(/\.metadata\.json$/).test(docName) in fromJSON() before processing them further.
I'm not sure if this is related but I get the following stacktrace from a fresh dump using mongodump:
❯ node seed.js
Error: corrupt bson message
at deserialize (/path-to-project/node_modules/mongodb-restore/node_modules/bson/lib/bson/parser/deserializer.js:27:9)
at BSON.deserialize (/path-to-project/node_modules/mongodb-restore/node_modules/bson/lib/bson/bson.js:115:10)
at /path-to-project/node_modules/mongodb-restore/index.min.js:89:24
at Array.forEach (<anonymous>)
at fromBson (/path-to-project/node_modules/mongodb-restore/index.min.js:81:48)
at /path-to-project/node_modules/mongodb-restore/index.min.js:113:36
at meta (/path-to-project/node_modules/mongodb-restore/index.min.js:187:16)
at /path-to-project/node_modules/mongodb-restore/index.min.js:112:18
at handleCallback (/path-to-project/node_modules/mongodb-restore/node_modules/mongodb/lib/utils.js:95:56)
at /path-to-project/node_modules/mongodb-restore/node_modules/mongodb/lib/db.js:512:22
❯ tree mongo-seed/dump
mongo-seed/dump
└── reach-engine
├── MyDummyCollection.bson
└── MyDummyCollection.metadata.json
1 directory, 2 files
I'm using mongo:3.4-jessie docker image.
Edit: I deleted MyDummyCollection.metadata.json but it's still failing with the same error.