0

I'm a newbie to mongo, and I've written the following script to clone a database in Mongo:

echo 'Enter db to clone: '
read dbToCopy
echo 'Enter name for cloned db'
read newDbName
dumpUri="mongodb://$un:$pw@$ip:$port/$dbToCopy?authSource=test"
restoreUri="mongodb://$un:$pw@$ip:$port/$newDbName?authSource=test"
mongodump --uri=$dumpUri --archive|mongorestore --uri="$restoreUri" --archive

I'm getting the below output & error, and can't find any information online. Any ideas, or leads that I could follow?

2020-02-20T15:28:01.592-0800    writing *****.Stacks to archive on stdout
2020-02-20T15:28:01.594-0800    writing *****.Queues to archive on stdout
2020-02-20T15:28:01.596-0800    writing *****.LFRs to archive on stdout
2020-02-20T15:28:01.624-0800    Failed: archive writer: error writing data for collection ***** to disk: error reading collection: Failed to parse: { find: "Nodes", skip: 0, snapshot: true, $readPreference: { mode: "secondaryPreferred" }, $db: ***** }. Unrecognized field 'snapshot'. / Mux ending but selectCases still open 4
2020-02-20T15:28:01.641-0800    preparing collections to restore from
2020-02-20T15:28:01.695-0800    reading metadata for *****.Nodes from archive on stdin
2020-02-20T15:28:01.696-0800    restoring *****.Nodes from archive on stdin
2020-02-20T15:28:01.717-0800    no indexes to restore
2020-02-20T15:28:01.718-0800    finished restoring *****.Nodes (0 documents)
2020-02-20T15:28:01.719-0800    done
2020-02-20T15:28:01.719-0800    Failed: error demultiplexing archive; archive finished before all collections were seen (*****.LFRs)```

I tried using --nsfrom/--nsto, but I still get the same error.
  • Do that work, if you mongodump to file and then mongorestore from that file? – JJussi Feb 25 at 6:53
  • No - I get the same error – Jake Levi Mar 2 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.