Files
ai-contract-platform/yuqei-infra/backup

Production backup and restore verification

Application backup APIs are not infrastructure backups. Production evidence requires PostgreSQL custom dumps, contract-file archives, MinIO object exports, checksums, and a disposable database restore rehearsal.

Backup

Dry-run:

python3 yuqei-infra/backup/run-production-backup.py \
  --env-file /etc/yuqei/production.env

Maintenance-window backup:

python3 yuqei-infra/backup/run-production-backup.py \
  --env-file /etc/yuqei/production.env \
  --apply \
  --quiesce-writers \
  --prune-keep 14

BACKUP_HOST_DIR must normally be a separate NAS/NFS/OSS-mounted filesystem. --allow-local-target exists only for rehearsals and cannot be used as production disaster-recovery evidence.

Each completed directory contains:

  • three PostgreSQL custom-format dumps;
  • contract-files.tar.gz;
  • a MinIO bucket mirror;
  • manifest.json with release ID, image digests, sizes, and SHA-256 values.

Incomplete runs remain as .backup-*.partial with a FAILED marker and are never treated as completed backups.

Restore check

Checksum and archive verification is read-only:

python3 yuqei-infra/backup/verify-production-backup.py \
  --backup-dir /mnt/yuqei-v2-backups/backup-YYYYMMDDTHHMMSSZ

Disposable database restore rehearsal:

python3 yuqei-infra/backup/verify-production-backup.py \
  --backup-dir /mnt/yuqei-v2-backups/backup-YYYYMMDDTHHMMSSZ \
  --env-file /etc/yuqei/production.env \
  --restore-databases \
  --apply

The script creates only generated yuqei_restore_check_* databases and drops them in finally. It never restores into the configured production database names. Contract-file and MinIO artifacts are integrity-checked but are not written into production volumes by this command.

Scheduling

Install yuqei-production-backup.service and .timer under /etc/systemd/system, then use:

systemctl daemon-reload
systemctl enable --now yuqei-production-backup.timer
systemctl list-timers yuqei-production-backup.timer

The default timer uses a short nightly maintenance window. Change that only after validating an online cross-store consistency strategy.