Mongodb import/export via stdin-stdout

In the next example, mongoimport takes data passed to it on standard input (i.e. with a | pipe.)
Without the output specification (i.e. “-o collection.json”), mongoexport writes output to standard output (i.e. “stdout”).

mongoexport -d dbname -c colname | gzip > dump.txt.gz
zcat dump.txt.gz | mongoimport -d dbname -c colname
Bookmark the permalink.

One Response to Mongodb import/export via stdin-stdout

  1. Wxll says:

    Big Thnx! Exactly what I was looking for!

Leave a Reply

Your email address will not be published. Required fields are marked *