Skip to content

Instantly share code, notes, and snippets.

@kdoran
Last active January 14, 2019 22:00
Show Gist options
  • Save kdoran/13585aeaa2c737b8292b3177d8dc50c5 to your computer and use it in GitHub Desktop.
Save kdoran/13585aeaa2c737b8292b3177d8dc50c5 to your computer and use it in GitHub Desktop.
backup all couchdbs except system dbs every 30 days
#!/bin/bash
TIMESTAMP=$(date +"%d")
BACKUP_DIR="./backups"
export $(cat .env)
COUCHDB=$COUCHDB_USER:$COUCHDB_PASSWORD@127.0.0.1:5984
mkdir -p "$BACKUP_DIR"
dbs=`curl -X GET http://$COUCHDB/_all_dbs | grep -Po '[A-Za-z0-9_.]*'`
for db in $dbs; do
if [[ "$db" =~ ^_ ]]; then
continue
fi
curl -X GET http://$COUCHDB/$db/_all_docs\?include_docs\=true | gzip > "$BACKUP_DIR/$TIMESTAMP-$db.json.gz"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment