Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Mongodump specify the output and filename

Is there a way to specify the whole path when running mongodump? I tried using –out but what it does at the moment is saving into a file at my_given_path/database/collection_name.json.gz

I have the following:

path = file_path + '/' + database + '/' + collection + '/'
query_input = "{\\\"metadata_id\\\": {\\\"\$oid\\\": \\\"" + metadata_id + "\\\"}}"
command = "mongodump --uri " + connection_string + database + " " \
          "--collection=" + collection + " --query=\"" + query_input + "\" --gzip --out=" + path + " --quiet"

for which the file is saved at:
file_path/database/collection/database/collection.json.gz

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Ideally I would like to save it into
file_path/database/collection/metadata_id.json.gz

Would this be possible?

>Solution :

You can use the --archive=<file> flag instead of --out

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading