Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-2336

Wrong deprecation error message printed when restoring from stdin

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 100.0.0
    • Component/s: mongorestore
    • Labels:

      Description

      When reading bson data from stdin without the --archive flag, mongorestore reads the data as if reading a single BSON file, therefore requiring the specification of a collection. However, it also prints a deprecation message saying that specifying a collection is deprecated and to use --nsInclude instead, an option that does not work when restoring single BSON files. This warning should be updated to only be printed when restoring from stdin with --archive.

      e.g.

      ~/mongo $ cat dump/test/caf%C3%A9s.bson | ./mongodb-4.2.0-rc2/bin/mongorestore
      -u kayadmin -p abc123 --authenticationDatabase=admin --db test --collection
      cafes -
      2019-07-08T14:28:52.937-0400	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
      2019-07-08T14:28:52.938-0400	setting up a collection to be read from standard
      input
      2019-07-08T14:28:52.938-0400	restoring to existing collection test.cafes without
      dropping
      2019-07-08T14:28:52.938-0400	restoring test.cafes from -
      2019-07-08T14:28:53.002-0400	no indexes to restore
      2019-07-08T14:28:53.002-0400	finished restoring test.cafes (2 documents, 0
      failures)
      2019-07-08T14:28:53.002-0400	2 document(s) restored successfully. 0 document(s)
      failed to restore.
       
      But, the following examples don't seem to work:
       
      cat dump/test/caf%C3%A9s.bson | ./mongodb-4.2.0-rc2/bin/mongorestore -u kayadmin
      -p abc123 --authenticationDatabase=admin --nsInclude test.cafe -
      2019-07-08T14:42:35.814-0400	Failed: cannot restore from stdin without a
      specified collection
      2019-07-08T14:42:35.815-0400	0 document(s) restored successfully. 0 document(s)
      failed to restore.
       
       
       
      ~/mongo $ ./mongodb-4.2.0-rc2/bin/mongodump --port 27018 -u kayadmin -p abc123
      --authenticationDatabase=admin --db test --collection cafés |
      ./mongodb-4.2.0-rc2/bin/mongorestore -u kayadmin --authenticationDatabase=admin
      -p abc123 --db=test --collection cafes -  
      2019-07-08T14:25:15.159-0400	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
      2019-07-08T14:25:15.159-0400	setting up a collection to be read from standard
      input
      2019-07-08T14:25:15.159-0400	writing test.cafés to 
      2019-07-08T14:25:15.160-0400	done dumping test.cafés (2 documents)
      2019-07-08T14:25:15.194-0400	restoring test.cafes from -
      2019-07-08T14:25:15.265-0400	no indexes to restore
      2019-07-08T14:25:15.265-0400	finished restoring test.cafes (0 documents, 0
      failures)
      2019-07-08T14:25:15.265-0400	0 document(s) restored successfully. 0 document(s)
      failed to restore.
       
       
      ~/mongo $ ./mongodb-4.2.0-rc2/bin/mongodump --port 27018 -u kayadmin -p abc123
      --authenticationDatabase=admin --db test --collection cafés |
      ./mongodb-4.2.0-rc2/bin/mongorestore -u kayadmin -p abc123
      --authenticationDatabase=admin --nsInclude test.cafés - 
      2019-07-08T14:25:32.192-0400	Failed: cannot restore from stdin without a
      specified collection
      2019-07-08T14:25:32.192-0400	0 document(s) restored successfully. 0 document(s)
      failed to restore.
      2019-07-08T14:25:32.193-0400	writing test.cafés to 
      2019-07-08T14:25:32.194-0400	done dumping test.cafés (2 documents)
      

      Thank you to [~kaykim106@gmail.com] for finding this!

        Attachments

          Activity

            People

            Assignee:
            evgeni.dobranov Evgeni Dobranov
            Reporter:
            patrick.freed Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: