Skip to content

Instantly share code, notes, and snippets.

@mikeymckay
Forked from janoskk/couchclone.sh
Last active May 24, 2018 07:50
Show Gist options
  • Save mikeymckay/248406eb5592904c2928c9baf4de8ed0 to your computer and use it in GitHub Desktop.
Save mikeymckay/248406eb5592904c2928c9baf4de8ed0 to your computer and use it in GitHub Desktop.

Revisions

  1. mikeymckay revised this gist May 24, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion couchclone.sh
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,8 @@ EOF
    exit 1
    fi

    DBNAMES=`curl -s -X GET $1/_all_dbs | sed 's/\[//;s/\]//;s/"_[a-z]*"//g;s/[,\"]/ /g'`
    #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
  2. @janoskk janoskk created this gist May 28, 2014.
    25 changes: 25 additions & 0 deletions couchclone.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    #!/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

    DBNAMES=`curl -s -X GET $1/_all_dbs | sed 's/\[//;s/\]//;s/"_[a-z]*"//g;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