title: mongodump for collection larger than ram
body: <p>I am using a command like this to dump data from a remote machine:</p>
  
  <pre><code>mongodump --verbose \
            --uri="mongodb://mongousr:somepassword@host.domain.com:27017/somedb?authSource=admin" \
            --out="$BACKUP_PATH"
  </code></pre>
  
  <p>This fails like so:</p>
  
  <pre><code>Failed: error writing data for collection `somedb.someCollection` to disk: error reading collection: EOF
  </code></pre>
  
  <p><code>somedb.someCollection</code> is about 40GB. I don't have the ability to increase RAM to this size.</p>
  
  <p>I have seen two explanations. One is that the console output is too verbose and fills the RAM. This seems absurd, it's only a few kilobytes and it's on the client machine anyway. Rejected (but I am trying it again now with <code>--quiet</code> just to be sure).</p>
  
  <p>The more plausible explanation is that the host fills its RAM with <code>somedb.someCollection</code> data and then fails. The problem is that the 'solution' that I've seen proposed is to increase the RAM to be bigger than the size of the collection.</p>
  
  <p>Really? That can't be right. What's the point of mongodump with that limitation?</p>
  
  <p>The question: is it possible to mongodump a database with a collection that is larger than my RAM size? How?</p>
  
  <p>mongodump Client:</p>
  
  <pre><code>macOS
  mongodump --version
  mongodump version: 4.0.3
  git version: homebrew
  Go version: go1.11.4
     os: darwin
     arch: amd64
     compiler: gc
  OpenSSL version: OpenSSL 1.0.2r  26 Feb 2019
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code>built with docker FROM mongo:
  Reports: MongoDB server version: 4.0.8
  </code></pre>