title: Mongodb: Restoring database produces this error E11000 duplicate key error collection: DATABASE_NAME.users index: _id_ dup key
body: <p>I dumped my database using this command:</p>
  <blockquote>
  <p>mongodump --uri
  'mongodb+srv://ACCOUNT_NAME:PASSWORD@cluster0.fklgt.mongodb.net/DATABASE_NAME' --archive=&quot;DATABASE_DUMP&quot; --forceTableScan</p>
  </blockquote>
  <p>Then I tried to restore it using this:</p>
  <blockquote>
  <p>mongorestore --uri
  'mongodb+srv://ACCOUNT_NAME:PASSWORD@cluster0.fklgt.mongodb.net/DATABASE_NAME' --archive=&quot;DATABASE_DUMP&quot; --nsFrom='DATABASE_NAME.<em>' --nsTo='DATABASE_NAME_COPY.</em>'</p>
  </blockquote>
  <p>But, this is what gets logged for <strong>each collection</strong>:</p>
  <blockquote>
  <p>2021-11-28T13:28:48.359+0000    restoring to existing collection
  DATABASE_NAME.admins without dropping</p>
  <p>2021-11-28T13:28:48.359+0000    restoring DATABASE_NAME.admins from archive
  'DATABASE_DUMP'</p>
  <p>2021-11-28T13:28:48.464+0000    continuing through error: E11000
  duplicate key error collection: .admins index: <em>id</em> dup key: {
  _id: ObjectId('xxxxxxxxxxxxxxxxxxxxxxxxxx') }</p>
  <p>2021-11-28T13:28:48.464+0000    continuing through error: E11000
  duplicate key error collection: DATABASE_NAME.admins index: <em>id</em> dup key: {
  _id: ObjectId('yyyyyyyyyyyyyyyyyyyyyyyy') }</p>
  <p>2021-11-28T13:28:48.464+0000    finished restoring DATABASE_NAME.admins (0
  documents, 2 failures)</p>
  </blockquote>
  <p>And in the end this is what gets logged:</p>
  <blockquote>
  <p>2021-11-28T13:28:48.567+0000    no indexes to restore for collection
  DATABASE_NAME.admins</p>
  <p>2021-11-28T13:28:48.664+0000    0 document(s) restored successfully.
  152793 document(s) failed to restore.</p>
  </blockquote>
  <p>I usually dump and restore without any problem. So I have no idea why is this happening.</p>