Last active
January 22, 2024 07:42
-
-
Save dungmanh88/d44b0c9938bc5d6a752f2f5051b0787d to your computer and use it in GitHub Desktop.
Dump multiple collections of a db in mongodb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
db=<db> | |
collection_list="<collection1> <collection2> <collection3>" | |
host=127.0.0.1 | |
port=<port> | |
out_prefix=/Temp | |
for collection in $collection_list; do | |
echo $collection | |
out_dir="${out_prefix}/${db}_${collection}/" | |
mkdir -p ${out_dir} | |
mongodump --host $host --port $port --collection $collection --db $db --out ${out_dir} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment