# 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