4.6 KiB
Scope correction implementation report
Summary
Implemented the approved backup scope correction for Dragon's Stash. Backups and restores now cover only:
- PostgreSQL logical custom-format dump plus manifest/migration metadata.
tdlib_stateworker Telegram session volume.tdlib_bot_statebot Telegram session volume.
The implementation no longer treats manual_uploads, completed local STL binaries, or tmp_zips as protected backup data. Future channel forwarding and archive/STL-content integrity auditing remain out of scope.
Changed files
-
docker-compose.yml- Removed the backup service's read-only
manual_uploads:/data/uploadsmount. - Kept the normal operational app/worker
manual_uploadsmounts. - Kept both TDLib backup mounts.
- Removed the backup service's read-only
-
scripts/backup/container-entrypoint.sh- Removed
/data/uploadsas a required mounted directory. - Removed uploads from the manifest
volumePaths. - Removed the
source:uploadsRestic tag. - Removed uploads from the Restic source list.
- Kept database dump, manifest, worker TDLib, and bot TDLib sources/tags.
- Removed
-
scripts/backup/restore.sh- Removed restored uploads variables.
- Removed uploads staging validation.
- Removed manual uploads volume discovery, safety archive, replacement, and rollback.
- Removed retained/manual upload file-path verification.
- Removed temporary database verification that existed only for local upload file references.
- Preserved guarded
restore-liveconfirmation, backup mount/repository checks, service stop/start handling, safety PostgreSQL dump, TDLib volume safety archives, TDLib volume replacement/rollback, andpg_restore --list/pg_restore --exit-on-errorvalidation.
-
prisma/schema.prisma- Removed
ManualUploadFile.retainedAt.
- Removed
-
prisma/migrations/20260722100000_remove_retained_manual_files/migration.sql- Added forward migration:
ALTER TABLE "manual_upload_files" DROP COLUMN IF EXISTS "retainedAt"; - Preserved the existing committed migration that added
retainedAt.
- Added forward migration:
-
src/app/api/uploads/route.ts- Removed
retainedAt: new Date()from manual upload file creation.
- Removed
-
worker/src/manual-upload.ts- Restored final best-effort cleanup of
/data/uploads/<uploadId>using the olderpath.join("/data/uploads", uploadId)behavior.
- Restored final best-effort cleanup of
-
scripts/backup/README.md- Rewrote backup set and restore rehearsal docs around PostgreSQL plus both TDLib volumes only.
- Removed local STL file, retainedAt, upload path, retained file reference, and restored checksum checks.
- Clarified that STL binaries remain in Telegram and recovery preserves database mappings/Telegram IDs.
- Kept monthly
restic check --read-dataand disposable restore rehearsal runbook. - Explicitly left future channel forwarding and archive/STL-content integrity auditing out of scope.
-
README.md- Updated the production backup summary to name PostgreSQL logical dump plus Telegram session volumes as the protected set.
- Clarified that
manual_uploadsand temporary ZIPs are excluded and STL binaries remain in Telegram.
Verification
-
git diff --check- Passed.
-
bash -n scripts/backup/container-entrypoint.sh scripts/backup/run-backup.sh scripts/backup/restore.sh- Local
bashfailed because Windows only had the WSL shim and no installed WSL distribution. - Passed via Docker fallback:
docker run --rm --entrypoint bash -v E:\Projects\DragonsStash:/work:ro -w /work postgres:16-alpine -n scripts/backup/container-entrypoint.sh scripts/backup/run-backup.sh scripts/backup/restore.sh
- Local
-
npx prisma validate- Passed.
-
npm run build- Passed.
-
cd worker && npm run build- Passed.
-
Focused backup/restore scope assertions
- Backup shell paths assertion passed: no
manual_uploads,/data/uploads,retainedAt, upload source tag, or upload-restore helper references inscripts/backup/*.sh. - Compose backup service assertion passed: no
manual_uploads,/data/uploads,retainedAt, orsource:uploadsin thebackupservice block. - Active retainedAt assertion passed: no
retainedAtin active Prisma schema, upload API, worker source, or backup shell scripts. - Active backup/restore upload-source assertion passed: no
manual_uploads,/data/uploads, ordata/uploadsin backup/restore shell scripts. - Remaining expected matches are limited to normal operational app/worker upload mounts and paths, docs stating exclusions, and the historical add/drop migrations.
- Backup shell paths assertion passed: no
Concerns
- None for implementation scope.
- Environment note: local Bash is unavailable because WSL has no installed distribution; Bash syntax was verified inside Docker instead.