mongorestore dropping collections using -drop option

John Jai picture John Jai · Mar 3, 2015 · Viewed 9k times · Source

Suppose if I have a database testdb with two collections collA and collB and try to restore only collB from a dump.

Will using --drop option with mongorestore drops both the existing collections (collA and collB) from testdb even though only collB is in the dump?

I am using MongoDB 2.6.5

Answer

Sn00p picture Sn00p · Oct 22, 2015

No, actually, according to the official documentation :

--drop Before restoring the collections from the dumped backup, drops the collections from the target database. --drop does not drop collections that are not in the backup.