When I’m restoring the backup using “mongorestore” all the DB content is being restored.
I’m looking for a way to restore only specific collection from the backup to a new or same DB.
I’ve tried to use --nsInclude, --nsFrom and --nsTo flags, but they aren’t helping.
Is there any possible way to achieve what I’ve described above?
Hi @Denis_Lezgin and welcome to the community!
I don’t remember precisely how to do it, but have you tried in nsFrom and nsTo to give the full namespace to try to restore the specific collection (i.e. database.collection)?
If that doesn’t work, I will do some tests tonight to give you a precise answer.
c. Finally we can restore the specific collection where we want.
Another way:
a. Restore directly the collection test1 from databaseToDump to databaseRestored (or where you want), but it generate some “duplicate key error collection”, because it also tries to restore the other existing collections in the same source db:
@Denis_Lezgin , After restoring it to new database . You can also use $out aggregation operator , to restore to specified collection . You dont have to make a dump again
New & Unread Topics
Topic list, column headers with buttons are sortable.