Created
September 19, 2022 14:49
-
-
Save jamesholcomb/54ee58e673717e14e2f9226f21a9fc73 to your computer and use it in GitHub Desktop.
Clones a mongodb collection and its indexes into __collection__
This file contains 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 | |
if [[ -z "$1" || -z "$2" ]] | |
then echo -e "Usage: clone-collection.sh <db> <collection>"; exit 1 | |
fi | |
# clones a mongodb collection and its indexes into __collection__ | |
mongodump -v -d $1 -c $2 --out=- | mongorestore -v -d $1 -c __$2__ --drop --dir=- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment