Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-9954

Clarify what --nsInclude does exactly in mongorestore

      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.

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            jaap@q42.nl Jaap Taal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              4 years, 30 weeks, 2 days ago