Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mongodb dump multiple collections script
#!/bin/bash
host=127.0.0.1
port=27017
authDB=admin
db=[YourDB]
user=root
pwd=[YourPassword]
collections="[Collection1] [Collection2]"
output_folder="./export/"
for collection in $collections; do
echo $collection
mongodump --host $host --port $port -u $user -p $pwd --authenticationDatabase $authDB --collection $collection --db $db --out ${output_folder}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment