forked from neelabalan/mongodb-sample-dataset
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.sh
More file actions
25 lines (22 loc) · 750 Bytes
/
script.sh
File metadata and controls
25 lines (22 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
###########################################################
# Ussage ( * = optional ): #
# ./script <db-address> <db-port> *<username> *<password> #
###########################################################
if [ ! -z "$3" ]; then
if [ ! -z "$4" ]; then
echo "Using password authentication!"
auth="--authenticationDatabase admin -u $3 -p $4"
fi
fi
#echo $auth
for coll in *; do
if [ -d "${coll}" ] ; then
echo "$coll"
for file in $coll/*; do
mongoimport --drop --host $1 --port $2 --db "$coll" --collection "$(basename $file .json)" --file $file $auth
#echo "$(basename $file .json)"
#echo "$file"
done
fi
done