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
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.
When used --drop, mongorestore will drop the collections if they are existing in both DB as well as in backup collection. It will not drop the collections which are not there in the Backup collection.
so in your example, collB will be dropped and restored, while collA remains untouched.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With