Skip to content

Instantly share code, notes, and snippets.

@olecksamdr
Last active August 27, 2020 11:01
Show Gist options
  • Save olecksamdr/aaeb00dda1e5623899040f2dc98857a3 to your computer and use it in GitHub Desktop.
Save olecksamdr/aaeb00dda1e5623899040f2dc98857a3 to your computer and use it in GitHub Desktop.
Dump several collections from mongodb server
collections=( collectionName1 collectionName2 collectionName3 collectionName4 )
for c in ${collections[@]}
do
mongodump \
--uri "..." \
--collection=$c \
--out "$(pwd)/staging/$(date +"%m-%d-%y")"
done
mongorestore \
--uri "mongodb://localhost:27017" \
-d $S_DBDATABASE \
"$(pwd)/staging/08-27-20/dbName" \
--drop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment