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
44 lines
1.6 KiB
Markdown
44 lines
1.6 KiB
Markdown
# Phase 2: Backup API Endpoints
|
|
|
|
**Status:** ⬜ Not Started
|
|
**Parent plan:** [PLAN.md](./PLAN.md)
|
|
**Domain:** backend
|
|
|
|
## Objective
|
|
Expose backup operations via REST API and wire autobackup scheduling.
|
|
|
|
## Tasks
|
|
|
|
- [ ] Task 1: Create `internal/api/backups.go` with handlers
|
|
- `POST /api/backups` — trigger manual backup
|
|
- `GET /api/backups` — list all backups
|
|
- `GET /api/backups/{id}/download` — download backup file
|
|
- `DELETE /api/backups/{id}` — delete backup
|
|
- `POST /api/backups/{id}/restore` — restore from backup
|
|
- [ ] Task 2: Register routes in router.go (admin-only)
|
|
- [ ] Task 3: Add backup engine to Server struct
|
|
- SetBackupEngine method (same pattern as SetProxyManager)
|
|
- [ ] Task 4: Wire autobackup cron in main.go
|
|
- Create backup engine on startup
|
|
- If backup_enabled, schedule cron job
|
|
- Graceful shutdown: stop cron
|
|
- [ ] Task 5: Update settings handler to restart autobackup cron on settings change
|
|
- [ ] Task 6: Add GET /api/settings response fields for backup settings
|
|
|
|
## Files to Modify/Create
|
|
- `internal/api/backups.go` — new handler file
|
|
- `internal/api/router.go` — register routes, add engine field
|
|
- `cmd/server/main.go` — wire engine, schedule cron
|
|
- `internal/api/settings.go` — include backup fields in GET/PUT
|
|
|
|
## Acceptance Criteria
|
|
- All CRUD endpoints work for backups
|
|
- Manual backup creates file and returns metadata
|
|
- Download streams the backup file
|
|
- Restore replaces DB (may require restart)
|
|
- Autobackup runs on configured interval
|
|
- Settings change updates cron schedule
|
|
|
|
## Handoff to Next Phase
|
|
<!-- Filled in after completion -->
|