title: Mongorestore from stdin
body: <p><strong>Has someone ever managed to restore a mongodump from stdin?</strong></p>
  
  <p>I generated the backup file using the referenced command:</p>
  
  <pre><code>mongodump --archive &gt; file
  </code></pre>
  
  <p>But the reference never explains in what format the archive is, or how to restore it. Some people say you have to inject it from stdin, but they remains a mystery as <em>there is no evidence that it is actually possible</em>.</p>
  
  <p>As a matter of fact, I did the following tries, without any success:</p>
  
  <pre><code>cat file | mongorestore
  mongorestore -vvvvv --archive &lt; file
  mongorestore -vvvvv --archive=file
  </code></pre>
  
  <p>All these commands end up with the same error:</p>
  
  <pre><code>Failed: stream or file does not appear to be a mongodump archive
  </code></pre>
  
  <p>For information, I managed to restore an archive that was generated the classic way.</p>
  
  <p><strong>Why do I need to use the --archive to stdout?</strong></p>
  
  <p>My mongodb is inside a docker.</p>
  
  <p>The option I'm using now creates the backup file <em>inside</em> the docker, that I <em>then copy to the host</em>, using the docker cp command, so I <em>use twice the space</em> needed (before it's removed inside the container).</p>
  
  <p>Unfortunately, the docker has no mount from the host, and I cannot (yet) restart it to add the option. I was looking for a quick option.</p>