[DOCS-9954] Clarify what --nsInclude does exactly in mongorestore Created: 01/Mar/17  Updated: 30/Oct/23  Resolved: 01/Oct/19

Status: Closed
Project: Documentation
Component/s: manual, Server, tools
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Bug Priority: Minor - P4
Reporter: Jaap Taal Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to DOCS-12579 mongorestore docs show deprecated exa... Closed
Participants:
Days since reply: 4 years, 19 weeks, 1 day ago
Epic Link: DOCSP-1769

 Description   

The docs for 3.4 about --nsInclude were confusing to me.

Specifically, the phrases specify multiple collections and matches the smallest valid occurence seem to contradict each other.

I'm coming from 3.2, for that version I created a script that downloads a backup, unzips it and restores the database to the local mongodb:

(cd dump && tar xf $DBNAME.tgz)
mongo --eval "db.dropDatabase()" $DBNAME
mongorestore -d $DBNAME dump/$DBNAME

That command issues a warning in 3.4:

the --db and --collection args should only be used when restoring from a BSON file. Other uses are deprecated and will not exist in the future; use --nsInclude instead

For me it's unclear how to map -d to --nsInclude.

The full docs (https://docs.mongodb.com/manual/reference/program/mongorestore/#cmdoption-nsinclude):

--nsInclude <namespace pattern>
New in version 3.4.

Includes only the specified namespaces in the restore operation. By enabling you to specify multiple collections to restore, --nsInclude offers a superset of the functionality of the --collection option.

--nsInclude accepts a namespace pattern as its argument. The namespace pattern permits --nsInclude to refer to any namespace that matches the specified pattern. mongorestore matches the smallest valid occurence of the namespace pattern.

Use asterisks as wild cards. Escape all literal asterisks and backslashes with a backslash. Restore Collections Using Wild Cards provides an example of using asterisks as wild cards.



 Comments   
Comment by Kay Kim (Inactive) [ 01/Oct/19 ]

Updated the definition for --nsInclude to:

 

Specifies a namespace pattern (e.g. "test.myCollection", "reporting.", "dept.bar") to restore only the namespaces that match the pattern. In the pattern, you can use asterisks * as wild cards. For an example of the wildcard pattern, see Restore Collections Using Wild Cards.

 

Updated the definition for --db to include the blurb:

 

The use of --db and --collection options are deprecated when restoring from a directory or an archive file. Instead, to restore from an archive or a directory, see --nsInclude instead.

 

Comment by Kelsey Schubert [ 01/Mar/17 ]

Hi q42jaap,

Thanks for the report. Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. Since this issue affects our documentation, I've moved it our DOCS project where we track improvements to our documentation. Please continue to watch this ticket for updates.

For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag.

Kind regards,
Thomas

Generated at Thu Feb 08 07:59:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.