mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
The nightly off-host job reports counts — uploaded, failed, total — and a count cannot name the account it is failing for. A cohort where one object has been refused every night for a month reads as "99 uploaded, 1 failed" each time, which looks like weather rather than like an account with no disaster-recovery copy at all. The worker now writes a ledger row when an object lands (account, instant, size), and Admin → Backups gains a second card that rates every account against the nightly schedule: fresh inside one run, due when one run produced nothing, stale when two did not, never when no object has ever landed. On a host without BACKUP_S3_* the card says off-host backup is not configured and stops there. The verdicts are computed from the ledger, never from a bucket listing: the worker's grant is deliberately PutObject + GetObject, and an admin page must not put the operator's credentials on its render path to state a number the database already holds.
17 lines
679 B
SQL
17 lines
679 B
SQL
-- One row per account, written by the nightly off-host backup job when an
|
|
-- object lands in the bucket. The admin console reads it to say, per account,
|
|
-- whether the newest off-host copy is as fresh as the schedule promises,
|
|
-- without the page ever talking to the bucket.
|
|
CREATE TABLE "offhost_backup_state" (
|
|
"user_id" TEXT NOT NULL,
|
|
"last_success_at" TIMESTAMP(3) NOT NULL,
|
|
"size_bytes" INTEGER NOT NULL,
|
|
|
|
CONSTRAINT "offhost_backup_state_pkey" PRIMARY KEY ("user_id")
|
|
);
|
|
|
|
ALTER TABLE "offhost_backup_state"
|
|
ADD CONSTRAINT "offhost_backup_state_user_id_fkey"
|
|
FOREIGN KEY ("user_id") REFERENCES "users"("id")
|
|
ON DELETE CASCADE ON UPDATE CASCADE;
|