Skip to content

Instantly share code, notes, and snippets.

@brugnara
Created January 3, 2015 23:21
Show Gist options
  • Save brugnara/80f980e4e33da7b87408 to your computer and use it in GitHub Desktop.
Save brugnara/80f980e4e33da7b87408 to your computer and use it in GitHub Desktop.
Extract meteor deploy mongo credential and execute mongodump for you.
#!/bin/sh
#
# Daniele Brugnara
#
# usage:
# meteor mongo xyz.meteor.com --url | ./do.sh
#
read mongo_auth
db_name=`echo $mongo_auth | awk '{split($0,array,"/")} END{print array[4]}'`
ar=`echo $mongo_auth | 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
mongodump -h $host --port 27017 --username $username --password $password -d $db_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment