feat(backup): replace JSON import/export with SQLite database backup system
Replace the JSON-based import/export with a proper backup system that copies the SQLite database file directly. Supports manual on-demand backups, periodic scheduled backups via node-cron, configurable retention, file download, and full database restore. - Add backupService with VACUUM INTO for safe DB copies - Add backupScheduler following healthcheckScheduler pattern - Add 6 admin API endpoints (create, list, download, restore, delete, schedule) - Add BackupPanel UI with backup table, confirmation dialogs, schedule config - Add backup fields to SystemSettings schema - Remove old ImportExportPanel, exportService, importService, and related code
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
# Feature Context: Database Backup & Restore
|
||||
|
||||
## Configuration
|
||||
- **Development mode:** Automated
|
||||
- **Execution mode:** Direct
|
||||
- **Strategy:** Big Bang
|
||||
- **Build:** `npm run build`
|
||||
- **Test:** `npm run test`
|
||||
- **Lint:** `npm run lint`
|
||||
- **Dev server:** `npm run dev` (port: 5173)
|
||||
|
||||
## Current State
|
||||
Starting implementation. Existing import/export code is still in place — will be removed in Phase 4.
|
||||
|
||||
## Tech Stack
|
||||
- SvelteKit 5 + TypeScript
|
||||
- Prisma ORM with SQLite (`data/launcher.db`)
|
||||
- node-cron (already a dependency, used by healthcheckScheduler)
|
||||
- Zod validation
|
||||
- Tailwind CSS + bits-ui components
|
||||
- svelte-i18n for localization
|
||||
- lucide-svelte for icons
|
||||
|
||||
## Key Patterns from Codebase
|
||||
- Services in `src/lib/server/services/` — pure functions, Prisma transactions
|
||||
- API routes follow SvelteKit conventions with admin auth guards
|
||||
- Scheduler pattern: `src/lib/server/jobs/healthcheckScheduler.ts` — cron start/stop, wired in hooks.server.ts
|
||||
- Admin components in `src/lib/components/admin/`
|
||||
- Audit logging via `auditLogService.ts`
|
||||
|
||||
## Cross-Phase Dependencies
|
||||
- Phase 2 depends on Phase 1 (backupService)
|
||||
- Phase 3 depends on Phases 1+2 (API endpoints)
|
||||
- Phase 4 is independent cleanup
|
||||
|
||||
## Implementation Notes
|
||||
- Using `VACUUM INTO` for safe backup creation (no locking)
|
||||
- Backups stored in `data/backups/` directory
|
||||
- Restore requires Prisma disconnect → file swap → reconnect
|
||||
- SystemSettings gets new fields: backupEnabled, backupCronExpression, backupMaxCount
|
||||
@@ -0,0 +1,39 @@
|
||||
# Feature: Database Backup & Restore
|
||||
|
||||
**Branch:** `feature/database-backup`
|
||||
**Base branch:** `master`
|
||||
**Created:** 2026-04-02
|
||||
**Status:** 🟡 In Progress
|
||||
**Strategy:** Big Bang
|
||||
**Mode:** Automated
|
||||
**Execution:** Direct
|
||||
|
||||
## Summary
|
||||
Replace JSON import/export with SQLite file-copy backup system. Support manual on-demand backups, optional periodic scheduling via node-cron, configurable retention (max backup count), download capability, and full database restore.
|
||||
|
||||
## Build & Test Commands
|
||||
- **Build:** `npm run build`
|
||||
- **Test:** `npm run test`
|
||||
- **Lint:** `npm run lint`
|
||||
|
||||
## Phases
|
||||
|
||||
- [ ] Phase 1: Backup Service & API Endpoints [domain: backend] → [subplan](./phase-1-backup-service.md)
|
||||
- [ ] Phase 2: Periodic Backup Scheduler [domain: backend] → [subplan](./phase-2-backup-scheduler.md)
|
||||
- [ ] Phase 3: Frontend BackupPanel [domain: frontend] → [subplan](./phase-3-backup-panel.md)
|
||||
- [ ] Phase 4: Cleanup Import/Export [domain: fullstack] → [subplan](./phase-4-cleanup.md)
|
||||
|
||||
## Phase Progress Log
|
||||
|
||||
| Phase | Domain | Status | Review | Build | Committed |
|
||||
|-------|--------|--------|--------|-------|-----------|
|
||||
| Phase 1: Backup Service & API | backend | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
||||
| Phase 2: Backup Scheduler | backend | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
||||
| Phase 3: BackupPanel UI | frontend | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
||||
| Phase 4: Cleanup | fullstack | ⬜ Not Started | ⬜ | ⬜ | ⬜ |
|
||||
|
||||
## Final Review
|
||||
- [ ] Comprehensive code review
|
||||
- [ ] Full build passes
|
||||
- [ ] Full test suite passes
|
||||
- [ ] Merged to `master`
|
||||
Reference in New Issue
Block a user