8

I'm trying to clone a remotely hosted collection to my local Mongo database. I tried opening up the mongo console in the local environment and issued:

db.runCommand({cloneCollection: "<dbname.colname>", from: "<remotehost:port>"})

It fails with

"errmsg" : "exception: nextSafe(): { $err: \"not authorized for query on <dbname>.system.namespaces\", code: 16550 }",
"code" : 13106,

How do I properly authorize with the remote server to clone the collection?

1 Answer 1

8

Unfortunately that's currently not possible. There is a Jira ticket open for this feature. As a workaround you could consider using mongodump --collection and mongorestore.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I ended up using mongoexport and mongoimport to clone the collections.
That's a viable option too, although keep in mind that mongodump produces BSON output which preserves the richer type information of BSON more accurately than mongoexport, which produces JSON output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.