# Phase 1: Backup Engine & Settings **Status:** ⬜ Not Started **Parent plan:** [PLAN.md](./PLAN.md) **Domain:** backend ## Objective Create the core backup engine and extend settings to support backup configuration. ## Tasks - [ ] Task 1: Add backup settings fields to Settings model - `BackupEnabled` bool (default false) - `BackupIntervalHours` int (default 24) - `BackupRetentionCount` int (default 10) - [ ] Task 2: Add migration columns in store.go - [ ] Task 3: Update GetSettings/UpdateSettings queries - [ ] Task 4: Create `backups` metadata table - id, filename, size_bytes, backup_type (manual/auto), created_at - [ ] Task 5: Create `internal/backup/engine.go` - Engine struct with db path, backup dir - `CreateBackup(backupType string) (Backup, error)` — VACUUM INTO timestamped file - `ListBackups() ([]Backup, error)` — read from metadata table - `GetBackup(id string) (Backup, error)` - `DeleteBackup(id string) error` — delete file + metadata - `RestoreBackup(id string) error` — copy backup over main DB - `DownloadPath(id string) (string, error)` — return file path for download - [ ] Task 6: Create `internal/store/backups.go` — CRUD for backup metadata - [ ] Task 7: Create backup directory on engine init (`DATA_DIR/backups/`) ## Files to Modify/Create - `internal/store/models.go` — add Backup struct, extend Settings - `internal/store/store.go` — add migration + backups table - `internal/store/settings.go` — update queries - `internal/store/backups.go` — backup metadata CRUD - `internal/backup/engine.go` — core backup logic ## Acceptance Criteria - Backup engine can create a backup file via VACUUM INTO - Backup metadata stored in DB - Backup files stored in DATA_DIR/backups/ - Settings include backup configuration fields - Delete removes both file and metadata ## Handoff to Next Phase