a9c7775bb7
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
1.9 KiB
1.9 KiB
Phase 1: Backup Engine & Settings
Status: ⬜ Not Started Parent plan: 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
BackupEnabledbool (default false)BackupIntervalHoursint (default 24)BackupRetentionCountint (default 10)
- Task 2: Add migration columns in store.go
- Task 3: Update GetSettings/UpdateSettings queries
- Task 4: Create
backupsmetadata 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 fileListBackups() ([]Backup, error)— read from metadata tableGetBackup(id string) (Backup, error)DeleteBackup(id string) error— delete file + metadataRestoreBackup(id string) error— copy backup over main DBDownloadPath(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 Settingsinternal/store/store.go— add migration + backups tableinternal/store/settings.go— update queriesinternal/store/backups.go— backup metadata CRUDinternal/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