Suppose I have ssh access to a server with mongodb on it. However, suppose the server does not have mongoexport
installed, and I cannot install it. I can use mongo
, interactively or feed it a script. I wish to export a subset of the data and import it on my local computer. Ideally, I'd like to run a script or command that saves the data in the same format as mongoexport
, so I can import it with mongoimport
locally. https://stackoverflow.com/a/12830385/513038 doesn't work (as it has extra line breaks in the results), nor does using printjsononeline
instead, because some values get printed differently and I end up with "Bad characters" and "expecting number" errors when I run mongoimport
.
Any ideas? Again, I'd like to use mongoimport
if possible, but other sufficiently workable ways are acceptable, as well.