title: MongoDB - dump and restore across different host, db with oplog
body: <p>Is it possible to take a mongodump and mongorestore it to a different hosts, with different DB names, with oplog enabled? </p>
  
  <blockquote>
    <p>From: mongodb://user:password@source-hostname:source-port/db1</p>
    
    <p>To: mongodb://user:password@dest-hostname:dest-port/db5</p>
  </blockquote>
  
  <p>When I do a mongodump with oplog on the source MongoDB, it takes a dump of the entire DB.</p>
  
  <pre><code>mongodump --oplog --host &lt;source-hostname&gt; -u &lt;user&gt; -p &lt;password&gt; --port &lt;source-port&gt; --authenticationDatabase admin
  </code></pre>
  
  <p>Now for the restore, I want to restore to a different hostname, and the db-name is also different. Is there way to restore the data to this db, with the oplogReplay?</p>
  
  <pre><code>mongorestore --host &lt;dest-host&gt; --port &lt;dest-port&gt; --username &lt;user&gt; --password &lt;password&gt; --authenticationDatabase admin --oplogReplay --db &lt;db5&gt; &lt;path-to-dump&gt;/dump
  </code></pre>
  
  <p>If I use oplogReplay, I am getting the following error</p>
  
  <pre><code>Can only replay oplog on full restore
  </code></pre>
  
  <p>I do not want to do a full restore, as it will create the db-name as db1, whereas I want to make use of db5. Also, there are already multiple DBs on this destination host and I do not want to bombard with another new database.</p>
  
  <p>Any suggestions on this issue?</p>