Files
tiny-forge/plans/backup-management/phase-4-retention.md
T
alexei.dolgolyov a9c7775bb7 feat: configuration backup management with manual and auto backup
Add backup/restore functionality for the SQLite database. Users can
trigger manual backups, configure automatic backups on an interval
with retention policies, list/download/delete backups, and restore
from any backup.

- Backup engine using VACUUM INTO (safe with WAL mode)
- Backup metadata tracked in DB, files stored in DATA_DIR/backups/
- Settings: backup_enabled, backup_interval_hours, backup_retention_count
- API: POST/GET/DELETE /api/backups, download, restore endpoints
- Autobackup via cron scheduler with configurable interval
- Retention: prune on startup, after each backup (manual and auto)
- Orphan cleanup: removes backup files without metadata on startup
- Restore: replaces DB and triggers graceful server shutdown
- Settings UI: /settings/backup with toggle, interval, retention config
- Backup list with download, delete, restore actions
- i18n: English and Russian translations
2026-04-02 15:32:15 +03:00

34 lines
1.1 KiB
Markdown

# Phase 4: Retention & Cleanup
**Status:** ⬜ Not Started
**Parent plan:** [PLAN.md](./PLAN.md)
**Domain:** backend
## Objective
Implement automatic retention enforcement — prune old backups after each backup
operation and on server startup.
## Tasks
- [ ] Task 1: Add `Prune()` method to backup engine
- Delete backups exceeding retention count (keep N most recent)
- Return count of pruned backups
- [ ] Task 2: Call Prune after every CreateBackup (both manual and auto)
- [ ] Task 3: Call Prune on server startup
- [ ] Task 4: Clean up orphaned files (files in backup dir not in metadata)
- [ ] Task 5: Log pruning results
## Files to Modify/Create
- `internal/backup/engine.go` — add Prune method
- `cmd/server/main.go` — call prune on startup
## Acceptance Criteria
- Backups exceeding retention count are automatically deleted
- Both file and metadata are removed during pruning
- Orphaned files (no metadata) are cleaned up
- Pruning runs after each backup and on startup
- Pruning results logged
## Handoff to Next Phase
<!-- Filled in after completion -->