-
-
Save mikeymckay/248406eb5592904c2928c9baf4de8ed0 to your computer and use it in GitHub Desktop.
Create (if necessary) and replicate all databases from a couchdb server to another one
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 | |
# | |
# Janos Kasza (@janoskk) | |
# | |
# Creates (if necessary) and replicates all databases from a couchdb server to another one | |
# | |
if [ -z "$2" ]; then | |
cat <<EOF | |
Usage: $0 <sourceUrl> <targetUrl> | |
Creates (if necessary) and replicates all databases from a couchdb server to another one. | |
Note that the urls must not contain the trailing '/' and the targetUrl may need to contain | |
authentication for admin. | |
Example: $0 http://example.com:5984 http://admin:admin@localhost:5984 | |
EOF | |
exit 1 | |
fi | |
#include _users, etc | |
DBNAMES=`curl -s -X GET $1/_all_dbs | sed 's/\[//;s/\]//;s/[,\"]/ /g'` | |
for i in $DBNAMES; do | |
curl -s -X PUT $2/$i | |
curl -s -X POST $2/_replicate -d '{"source":"'$1/$i'", "target":"'$2/$i'"}' -H "Content-Type: application/json" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment