Add USB backup system with CRC32 verification

**USB Backup Features:**
- Automatic backup to multiple USB drives
- CRC32 checksum verification for data integrity
- Configurable backup paths in config.json
- Backup on write (recordings and greeting uploads)
- Corrupted backups automatically deleted
- Web interface for monitoring and testing

**Configuration:**
- Added backup section to config.example.json
- enabled: Enable/disable USB backup
- usb_paths: Array of USB mount points
- verify_crc: Enable CRC32 verification
- backup_on_write: Backup immediately after file write

**CRC32 Implementation:**
- calculate_crc32(): Compute file checksum
- 64KB chunk reading for memory efficiency
- Source and destination file verification
- Automatic cleanup of failed copies

**Backup Functions:**
- backup_file_to_usb(): Backup with verification
- get_usb_backup_status(): Check drive status
- Mount detection, write test, free space check
- Preserves directory structure on USB

**Web Interface:**
- USB Backup card with drive status display
- Green/Yellow/Red status indicators
- Free space monitoring
- Test backup button
- Real-time status refresh
- Detailed error reporting

**Integration:**
- Recordings backed up after save
- Greetings backed up after upload
- Backup results logged to console
- Non-blocking backup execution

**API Endpoints:**
- GET /api/backup/status - Drive status
- POST /api/backup/test - Test backup

**Documentation:**
- Complete USB backup guide in README
- Mount instructions for USB drives
- CRC verification explanation
- Backup directory structure
- Web interface usage guide

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-24 16:28:32 +07:00
parent 7e26373fe9
commit d07cb82772
3 changed files with 387 additions and 5 deletions

View File

@@ -19,6 +19,15 @@
"recordings_dir": "recordings",
"sounds_dir": "sounds"
},
"backup": {
"enabled": true,
"usb_paths": [
"/media/usb0",
"/media/usb1"
],
"verify_crc": true,
"backup_on_write": true
},
"web": {
"port": 8080,
"max_upload_size_mb": 50