Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
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.

backup.shBlame37 lines · 1 contributor
f635e2fClaude1#!/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)
10set -euo pipefail
11
12REPO_DIR="/opt/gluecron"
13BACKUP_DIR="$REPO_DIR/backups"
14RETAIN_DAYS=14
15COMPOSE="docker compose -f docker-compose.standalone.yml"
16
17cd "$REPO_DIR"
18mkdir -p "$BACKUP_DIR"
19ts=$(date +%Y%m%d-%H%M%S)
20out="$BACKUP_DIR/gluecron-$ts.sql.gz"
21
22$COMPOSE exec -T postgres pg_dump -U gluecron gluecron | gzip > "$out"
23
24# Retention
25find "$BACKUP_DIR" -name 'gluecron-*.sql.gz' -mtime +$RETAIN_DAYS -delete
26
27# Optional offsite copy
28if [ -n "${BACKUP_RCLONE_REMOTE:-}" ] && command -v rclone >/dev/null 2>&1; then
29 rclone copy "$out" "$BACKUP_RCLONE_REMOTE" || echo "WARN: offsite copy failed"
30fi
31
32# Optional dead-man's-switch heartbeat (alerts you if a backup is ever missed)
33if [ -n "${HEALTHCHECK_PING_URL:-}" ]; then
34 curl -fsS -m 10 "$HEALTHCHECK_PING_URL" >/dev/null 2>&1 || true
35fi
36
37echo "$(date -Is) backup written: $out ($(du -h "$out" | cut -f1))"