gendesign/ops/gendesign-backup-forgejo.default.example
bot-backend 83be088263 feat(ops): missed-run detection for backups + Forgejo code/DB backup to S3
Deliverable 1: ops/backup.sh and tradein-mvp/deploy/backup-tradein-db.sh now
write a sentinel file on every verified-good run. A new ops/check-backup-
staleness.sh (separate cron entry, hourly) alerts via the existing Telegram
channel (same TELEGRAM_BOT_TOKEN/TELEGRAM_CHAT_ID idiom as ops/uptime-
healthcheck.sh, transition-tracked so it doesn't spam) if a sentinel goes
stale. Shared logic (notify/sentinel/state) factored into ops/lib-backup.sh
so it isn't triplicated; the two existing scripts' own hardening (integrity
checks, retention, etc.) is untouched.

Deliverable 2: ops/backup-forgejo.sh — Forgejo (git.gendsgn.ru) has no backup
today. Dumps the shared-postgres `forgejo` DB + tars the bare-repo tree, both
off-box to s3://gendsgn-backups/forgejo/ under a SEPARATE, narrower S3 key
(root-of-bucket writer key stays out of this). The key doesn't exist yet —
the script refuses to run and exits non-zero, loudly, until the four
FORGEJO_S3_* vars are filled in (see the example env file and PR description
for the exact bucket policy JSON to create it with).

Refs #2203, #2989
2026-08-21 15:37:19 +03:00

44 lines
2.8 KiB
Text

# Environment file for ops/backup-forgejo.sh (Forgejo code + DB backup, #2203).
#
# Install on the prod VM as a ROOT-OWNED, chmod-600 file that is NOT in git:
# sudo cp /opt/gendesign/ops/gendesign-backup-forgejo.default.example /etc/default/gendesign-backup-forgejo
# sudo chmod 600 /etc/default/gendesign-backup-forgejo
# sudo $EDITOR /etc/default/gendesign-backup-forgejo # fill in real S3 credentials
#
# DELIBERATELY a separate file from /etc/default/gendesign-backup (used by
# ops/backup.sh and tradein-mvp/deploy/backup-tradein-db.sh) — this backup
# uses a SEPARATE, narrower-scoped S3 service user that can ONLY PutObject
# under s3://gendsgn-backups/forgejo/*, nothing else. The prod-host writer
# key used by the other two backups (`gendsgn-backup-writer`) has root-of-
# bucket access; that key must NOT be reused here, and this key must NOT be
# put in /etc/default/gendesign-backup.
#
# THE KEY DOES NOT EXIST YET (as of #2203). Until a human creates the
# `gendsgn-backup-forgejo-writer` service user + bucket policy in the
# Selectel panel (see the #2203 PR description for the exact policy JSON —
# PutObject-only on arn:aws:s3:::gendsgn-backups/forgejo/*, explicit Deny on
# GetObject/ListBucket/Delete*) and fills in the four FORGEJO_S3_* vars
# below, ops/backup-forgejo.sh refuses to run and exits non-zero loudly. That
# is expected, not a bug.
#
# --- S3 off-site upload (Selectel S3-compatible). All four required. ---
#FORGEJO_S3_ENDPOINT=https://s3.ru-1.storage.selcloud.ru
#FORGEJO_S3_BUCKET=gendsgn-backups
#FORGEJO_S3_ACCESS_KEY=REPLACE_WITH_REAL_ACCESS_KEY_ONCE_CREATED
#FORGEJO_S3_SECRET_KEY=REPLACE_WITH_REAL_SECRET_KEY_ONCE_CREATED
# --- optional overrides (defaults are sensible; uncomment only to change) ---
#FORGEJO_S3_PREFIX=forgejo/ # key prefix inside the bucket; must match
# the policy's Resource path exactly
#KEEP=7 # how many recent local copies to retain
# (DB dumps and repo bundles are separate series)
#MIN_DB_DUMP_BYTES=2048 # sanity floor for the DB dump (small DB —
# config/issues/PRs/users, no git blobs)
#MIN_REPOS_BUNDLE_BYTES=10240 # sanity floor for the repo tar.gz
#LOCAL_BACKUP_DIR=/opt/gendesign/backups/forgejo
#FORGEJO_DIR=/home/gendesign/forgejo # Forgejo compose dir on the VM (NOT
# part of the gendesign git checkout)
#FORGEJO_REPOS_DIR=/home/gendesign/forgejo/data/forgejo/git/repositories
#PG_CONTAINER=gendesign-postgres-1 # Forgejo's DB lives in the SAME shared
# postgres container as the main app,
# as a separate `forgejo` user+database