Created
July 24, 2014 09:16
-
-
Save samarthbhargav/afa42c835487338edff5 to your computer and use it in GitHub Desktop.
A Shell Script to Export multiple collections
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
echo "Enter HostName:" | |
read host | |
echo "Enter DB Name:" | |
read dbname | |
echo "Enter Auth DB Name: (usually admin)" | |
read authdb | |
echo "Enter Username:" | |
read username | |
echo "Enter Password" | |
read password | |
echo "Credentials: Host: $host, DB:$dbname, AuthDB:$authdb, Username:$username, Password:$password" | |
while true; do | |
echo "Enter Collection to export: " | |
read collection | |
echo "Exporting Collection: $collection" | |
echo "Command: mongoexport --db $dbname --collection $collection --host $host --authenticationDatabase $authdb --username $username --password $password --out $collection" | |
mongoexport --db $dbname --collection $collection --host $host --authenticationDatabase $authdb --username $username --password $password --out $collection.json | |
echo "Export Done, Check $collection.json" | |
echo "Export Another Collection? [y/n] :" | |
read response | |
if [ "$response" != "y" ] | |
then | |
break | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment