Created
July 24, 2014 09:17
-
-
Save samarthbhargav/0d0c27832f7592588570 to your computer and use it in GitHub Desktop.
A Shell Script to Import Multiple Collections from a Folder
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
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" | |
echo "Enter Path to mongo_dump:" | |
read mongodump | |
for file in "$mongodump"/* | |
do | |
echo "Found file: $file" | |
echo "Command: mongoimport --db $dbname --collection `basename $file` --host $host --authenticationDatabase $authdb --username $username --password $password --file $file" | |
mongoimport --db $dbname --collection `basename $file` --host $host --authenticationDatabase $authdb --username $username --password $password --file $file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment