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

mongodump will not combine --uri and --db, forcing URI parsing and reassembly in shell scripts is problematic

    • Type: Icon: New Feature New Feature
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.0.4, 3.6.14
    • Component/s: mongodump
    • Labels:
      None

      This command:

      mongodump --uri=[atlas URI here] --db=specificdbname

      Throws the following error:

      error parsing command line options: illegal argument combination: cannot specify --db and --uri

      While a URI can convey the database name and certainly should be allowed to, hosting platforms like MongoDB Atlas provide developers with a general purpose URI to a cluster. In fact, the Atlas-provided URI contains the database name "test" but no one expects the developer to really want the "test" database.

      When scripting it is not uncommon that you need the "foo" database from the cluster. However rebuilding the URI in the context of a shell script is problematic. One can search-and-replace "/test", but there's no knowing if this convention of including "/test" is universal or even something that will continue, so you need extra logic to make sure it is there, etc.

      Yes, you can do a better job rebuilding the URL if you pull it into something like node or python but our little bash script just got awfully complicated. (:

      Please allow --uri and --db to be combined. --db should override the database name present in --uri.

      A commenter on issue TOOLS-2151 has also pointed out the inconsistency of refusing the combination in mongodump, but requiring the combination in mongorestore.

      Thanks!

            Assignee:
            Unassigned Unassigned
            Reporter:
            ops@apostrophecms.com Apostrophe Cloud
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: