Skip to content

Instantly share code, notes, and snippets.

@tlvince
Created September 25, 2015 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlvince/0a7caf8593c6c95a246a to your computer and use it in GitHub Desktop.
Save tlvince/0a7caf8593c6c95a246a to your computer and use it in GitHub Desktop.
Clone all design docs of a given CouchDB DB. Requires node and couchapp on PATH
#!/usr/bin/env bash
set -euo pipefail
url=${1:-}; [[ $url ]] || { echo "$0 http://couchdb.example.com/db" && exit 1; }
curl $url'/_all_docs?startkey="_design/"&endkey="_design/\uffff"' | \
node -pe "JSON.parse(require('fs').readFileSync('/dev/stdin')).rows.map(function(row){return row.id}).join('\n')" | \
while read ddoc; do couchapp clone "$url/$ddoc"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment