title: mongodump --oplog and per database restore
body: <p>I need to be able to <strong>restore</strong> a <strong>single database</strong>, even a single collection from a backup. Since <code>mongodump --oplog</code> only applies to a full instance (Replica Set), I made the following procedure to filter only the entries from the db that I want to restore from the <em>oplog.bson</em> generated by the --oplog option.
  Could someone tell me if this is correct or if I'm missing something?</p>
  
  <ol>
  <li><p>First I restore only the db (the db is <em>test</em> in this example) that I need</p>
  
  <blockquote>
    <p><code>mongorestore -d test dump/test</code></p>
  </blockquote></li>
  <li><p>Restore into a random collection the <em>oplog.bson</em> file generated by the --oplog option</p>
  
  <blockquote>
    <p><code>mongorestore -d oplog -c oplog  dump/oplog.bson</code></p>
  </blockquote></li>
  <li><p>Dump from the restored <em>oplog.bson</em> collection only the documents that refer to the db that I'm restoring</p>
  
  <blockquote>
    <p><code>mongodump -d oplog -c oplog -q "{ns:/^test[.]/}" -o oplog</code></p>
  </blockquote></li>
  <li><p>Restore with the --oplogReplay option using the last dump with filtered operations</p>
  
  <blockquote>
    <p><code>mongorestore --oplogReplay oplog/oplog</code></p>
  </blockquote></li>
  <li><p>Finally I drop the temporary oplog collection.</p>
  
  <blockquote>
    <p><code>mongo --eval "db.getSisterDB('oplog').dropDatabase()"</code></p>
  </blockquote></li>
  </ol>
  
  <p>Thanks in advance!</p>