Skip to content

Instantly share code, notes, and snippets.

@railscard
Created September 11, 2012 17:29
Show Gist options
  • Save railscard/3700041 to your computer and use it in GitHub Desktop.
Save railscard/3700041 to your computer and use it in GitHub Desktop.
Export bson data to mongodb
#!/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