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



    • New Feature
    • Status: Closed
    • Major - P3
    • Resolution: Gone away
    • 4.0.4, 3.6.14
    • None
    • mongodump
    • 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.





            Unassigned Unassigned
            ops@apostrophecms.com Apostrophe Cloud
            1 Vote for this issue
            5 Start watching this issue