Last active
February 18, 2016 19:21
-
-
Save DanAncona/86e214a07a610f8dec43 to your computer and use it in GitHub Desktop.
meteor mongo collection schlepper
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/sh | |
# A script for dumping and restoring a remote meteor mongo db | |
# Based on a script by Daniele Brugnara | |
# | |
# usage: | |
# dump_restore_remote | |
# | |
MONGO_CMD=`meteor mongo --url 'http://why-dev.meteor.com/'` | |
MONGO_URL="${MONGO_CMD}" | |
echo $MONGO_URL | |
db_name=`echo $MONGO_URL | awk '{split($0,array,"/")} END{print array[4]}'` | |
ar=`echo $MONGO_URL | tr '//' '\n' | grep client | tr ':' '\n' | head -n 2 | tr '@' '\n' | tr '\n' ':'` | |
username=`echo $ar | awk '{split($0,array,":")} END{print array[1]}'` | |
password=`echo $ar | awk '{split($0,array,":")} END{print array[2]}'` | |
host=`echo $ar | awk '{split($0,array,":")} END{print array[3]}'` | |
echo $host | |
echo $username | |
echo $password | |
echo $db_name | |
echo "mongodump -h $host --port 27017 --username $username --password $password -d $db_name -c positions" | |
# dump remote to local | |
#mongodump -h $host --port 27017 --username $username --password $password -d $db_name -c unitedstates | |
# restore local to remote | |
#mongorestore -h $host --port 27017 --username $username --password $password -d $db_name -c dump/why-dev_meteor_com/unitedstates.bson | |
# restore to local | |
mongorestore -h localhost --port 3001 -d meteor dump/why-dev_meteor_com/unitedstates.bson |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment