Created
September 11, 2012 17:29
-
-
Save railscard/3700041 to your computer and use it in GitHub Desktop.
Export bson data to mongodb
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 | |
# | |
# Converts all files in current directory | |
# from bson format to json and import | |
# them to mongodb collection. | |
# | |
# Usage: | |
# Put this script in bson files directory, | |
# run chmod +x bsonexport.sh | |
# | |
# ./bsonexport.sh <dbname> | |
for file in *.bson; | |
do | |
basename=$(basename $file .bson) | |
bsondump $basename.bson > $basename.json | |
mongoimport -d $1 -c $basename $basename.json | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment