Created
March 8, 2017 11:13
-
-
Save zweite/cea659b3afa19fb11acef1463586a922 to your computer and use it in GitHub Desktop.
backup mongo instance
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 | |
# $1 like 127.0.0.1:27029 | |
mongoUrl=$1 | |
querydb="echo 'show dbs;'| mongo "$mongoUrl" |awk '{if (NR>2 && NF==2){print \$1}}'" | |
dbs=`eval $querydb` | |
for db in $dbs; do | |
mongodump -h $mongoUrl -d $db -o ./ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment