CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
backup.sh
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| f635e2f | 1 | #!/usr/bin/env bash |
| 2 | # | |
| 3 | # Daily Postgres backup for the standalone box. Installed as a systemd timer by | |
| 4 | # scripts/standalone-deploy.sh. Keeps 14 days locally; optionally copies offsite | |
| 5 | # and pings a dead-man's-switch monitor. | |
| 6 | # | |
| 7 | # Optional env (set in /opt/gluecron/.env): | |
| 8 | # BACKUP_RCLONE_REMOTE e.g. r2:gluecron-backups (needs rclone configured) | |
| 9 | # HEALTHCHECK_PING_URL e.g. https://hc-ping.com/<uuid> (healthchecks.io) | |
| 10 | set -euo pipefail | |
| 11 | ||
| 12 | REPO_DIR="/opt/gluecron" | |
| 13 | BACKUP_DIR="$REPO_DIR/backups" | |
| 14 | RETAIN_DAYS=14 | |
| 15 | COMPOSE="docker compose -f docker-compose.standalone.yml" | |
| 16 | ||
| 17 | cd "$REPO_DIR" | |
| 18 | mkdir -p "$BACKUP_DIR" | |
| 19 | ts=$(date +%Y%m%d-%H%M%S) | |
| 20 | out="$BACKUP_DIR/gluecron-$ts.sql.gz" | |
| 21 | ||
| 22 | $COMPOSE exec -T postgres pg_dump -U gluecron gluecron | gzip > "$out" | |
| 23 | ||
| 24 | # Retention | |
| 25 | find "$BACKUP_DIR" -name 'gluecron-*.sql.gz' -mtime +$RETAIN_DAYS -delete | |
| 26 | ||
| 27 | # Optional offsite copy | |
| 28 | if [ -n "${BACKUP_RCLONE_REMOTE:-}" ] && command -v rclone >/dev/null 2>&1; then | |
| 29 | rclone copy "$out" "$BACKUP_RCLONE_REMOTE" || echo "WARN: offsite copy failed" | |
| 30 | fi | |
| 31 | ||
| 32 | # Optional dead-man's-switch heartbeat (alerts you if a backup is ever missed) | |
| 33 | if [ -n "${HEALTHCHECK_PING_URL:-}" ]; then | |
| 34 | curl -fsS -m 10 "$HEALTHCHECK_PING_URL" >/dev/null 2>&1 || true | |
| 35 | fi | |
| 36 | ||
| 37 | echo "$(date -Is) backup written: $out ($(du -h "$out" | cut -f1))" |