Files
settled-reach/tooling/db-backup
T
jpmschweitzerandClaude Opus 4.6 60ca9d951c feat(db): add database backup/restore tooling
- tooling/db-backup: copies shared settledreach.db to docs/backups/
  for git tracking (main branch only)
- tooling/db-install: restores from backup for new clones
- make db-backup / make db-install Makefile targets
- worktree-update skill runs make db-backup after merges on main

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:54:21 +01:00

24 lines
808 B
Bash
Executable File

#!/usr/bin/env bash
# Copy the shared database into git-tracked docs/backups/ for disaster recovery.
# Only runs on the main branch — called via `make db-backup`.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
WORKTREE_ROOT="$(dirname "$SCRIPT_DIR")"
DB_PATH="$(dirname "$WORKTREE_ROOT")/settledreach.db"
BACKUP_PATH="$WORKTREE_ROOT/docs/backups/settledreach.db.backup"
branch="$(git -C "$WORKTREE_ROOT" branch --show-current)"
if [ "$branch" != "main" ]; then
echo "error: db-backup only runs on the main branch (currently on '$branch')" >&2
exit 1
fi
if [ ! -f "$DB_PATH" ]; then
echo "error: shared database not found at $DB_PATH" >&2
exit 1
fi
cp "$DB_PATH" "$BACKUP_PATH"
echo "ok: backed up $(du -h "$BACKUP_PATH" | cut -f1) to docs/backups/settledreach.db.backup"