gendesign/ops/gendesign-backup.default.example
bot-backend 770492b8b3 fix(ops): бэкап не теряет роли, не глотает ошибки и умеет уезжать с машины (#2203)
- ops/backup.sh и tradein-mvp/deploy/backup-tradein-db.sh теперь дампят
  globals (pg_dumpall --globals-only) отдельным файлом с той же ретенцией
  и той же S3-выгрузкой — pg_dump по определению не включает роли/GRANT.
- Обе выгрузки проходят gzip -t + проверку трейлера дампа перед тем как
  считаться успешными; при провале файл удаляется, ретенция не трогается,
  выход ненулевой.
- Убран 2>/dev/null у pg_dump в обоих скриптах — ошибка дампа теперь
  видна в логе, а не глотается молча.
- tradein-backup.sh получил S3-выгрузку (по образцу ops/backup.sh, те же
  4 переменные, тот же способ через aws-cli контейнер) и env-переопределяемый
  порог минимального размера дампа; источник переменных —
  /etc/default/tradein-backup с фолбэком на /etc/default/gendesign-backup.
- Новый ops/restore-drill.sh — учебное восстановление в одноразовый
  postgis-контейнер без прод-томов, никогда не трогает боевую БД (в отличие
  от ops/restore.sh, который восстанавливает В БОЕВУЮ базу).
2026-08-20 22:13:58 +03:00

40 lines
2.3 KiB
Text

# Environment file for ops/backup.sh (MAIN gendesign DB backup, #71).
#
# Install on the prod VM as a ROOT-OWNED, chmod-600 file that is NOT in git:
# sudo cp /opt/gendesign/ops/gendesign-backup.default.example /etc/default/gendesign-backup
# sudo chmod 600 /etc/default/gendesign-backup
# sudo $EDITOR /etc/default/gendesign-backup # fill in real S3 credentials
#
# backup.sh sources this file if present. With NO S3 vars set, dumps stay
# local-only under /opt/gendesign/backups (retention KEEP=7). Fill these in to
# also push each dump off-box to S3 (recommended — local-only dies with the VM).
# backup.sh now also dumps cluster globals (roles/GRANTs, via `pg_dumpall
# --globals-only`) alongside the main dump — same S3 vars, same bucket, no
# separate config needed (#2203).
#
# tradein-mvp/deploy/backup-tradein-db.sh (separate DB, separate cron job)
# prefers its OWN env file at /etc/default/tradein-backup, but falls back to
# THIS file if that one doesn't exist — so filling in the S3 vars here also
# enables off-box upload for the tradein DB backup, unless you want the two
# DBs going to different buckets/creds (then create /etc/default/tradein-backup
# with its own S3_* vars instead).
#
# To rehearse a restore from a dump this script produced (safe, throwaway
# container, never touches prod) see ops/restore-drill.sh.
# --- S3 off-site upload (Selectel S3-compatible). All four required to enable. ---
#S3_ENDPOINT=https://s3.ru-1.storage.selcloud.ru
#S3_BUCKET=gendesign-backups
#S3_ACCESS_KEY=REPLACE_WITH_REAL_ACCESS_KEY
#S3_SECRET_KEY=REPLACE_WITH_REAL_SECRET_KEY
# --- optional overrides (defaults are sensible; uncomment only to change) ---
#KEEP=7 # how many recent local dumps to retain (applies to both
# the main dump series and the globals dump series)
#MIN_DUMP_BYTES=51200 # sanity floor for the MAIN dump; a dump smaller than
# this is treated as failed. No equivalent floor for the
# globals dump — a handful of roles legitimately gzips to
# well under this. tradein-backup.sh has its own,
# separate MIN_DUMP_BYTES (default 10240) — set in
# /etc/default/tradein-backup, not here.
#LOCAL_BACKUP_DIR=/opt/gendesign/backups