experiments in a post-browser web
1# Database Backup System
2
3## Overview
4
5Daily compressed backups of the SQLite database with manual controls in Settings > Diagnostic.
6
7## Configuration
8
9Backups are disabled by default. To enable:
10
111. Open Settings > Core
122. Set `backupDir` to your desired backup location (e.g., `~/sync/peek-backups`)
133. Backups will run automatically on app startup (daily)
14
15## Behavior
16
17- **Trigger**: On app startup, if >24 hours since last backup
18- **Format**: ZIP archive containing `datastore.sqlite` and `manifest.json`
19- **Filename**: `peek-backup-{profile}-{YYYY-MM-DD-HHmmss}.zip`
20- **Retention**: Keeps 7 most recent backups (configurable)
21- **Method**: Uses SQLite's `VACUUM INTO` for consistent copies without locking
22
23## Architecture
24
25### Files
26
27- `backend/electron/backup.ts` - Core backup logic
28- `app/config.js` - `backupDir` preference in core settings schema
29- `app/diagnostic.html` - Manual backup UI
30
31### IPC Handlers
32
33- `backup-get-config` - Get current backup configuration
34- `backup-set-config` - Update backup settings (retentionCount, lastBackupTime)
35- `backup-create` - Trigger manual backup
36- `backup-list` - List existing backups
37
38### Settings Storage
39
40- `backupDir` is stored in core settings (`extension_settings` table, extensionId=`core`, key=`prefs`)
41- `lastBackupTime` and `retentionCount` stored separately (extensionId=`backup`)
42
43## Manual Controls
44
45Available in Settings > Diagnostic > Backup Tools:
46
47- **Backup Now** - Create immediate backup
48- **List Backups** - Show existing backups with sizes and dates
49- **Open Backup Folder** - Open backup directory in Finder
50
51## Archive Contents
52
53```
54peek-backup-default-2026-01-19-143022.zip
55├── datastore.sqlite # VACUUM'd copy of database
56└── manifest.json # Metadata: version, timestamp, profile, table row counts
57```