Last active
January 14, 2019 22:00
-
-
Save kdoran/13585aeaa2c737b8292b3177d8dc50c5 to your computer and use it in GitHub Desktop.
backup all couchdbs except system dbs every 30 days
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 | |
TIMESTAMP=$(date +"%d") | |
BACKUP_DIR="./backups" | |
export $(cat .env) | |
COUCHDB=$COUCHDB_USER:[email protected]: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