Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restoring from BSON dump breaks when directory contains metadata files created by mongodump #15

Open
cdxOo opened this issue Jul 13, 2017 · 1 comment

Comments

@cdxOo
Copy link

cdxOo commented Jul 13, 2017

By default recent versions of mongodump create metadata files in the form of .metadata.json within the dump diretory. Theese files are not filtered and therefor restore breaks when tying to deserialize them as bson.

I suggest checking for !(/\.metadata\.json$/).test(docName) in fromJSON() before processing them further.

@GabLeRoux
Copy link

GabLeRoux commented Mar 21, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants