$ show giovi321/ios-backup-machine
The iOS Backup Machine is a self-contained backup appliance for iOS devices, designed to run on a single-board computer (Radxa Zero 3W) with a Waveshare e-Paper display and PiSugar UPS. The software provides a Flask-based web UI for configuration and monitoring, a background daemon that manages iPhone backups via libimobiledevice (idevicebackup2), remote sync via rsync over SSH with host key pinning, WireGuard VPN integration for secure remote access, and notification delivery via MQTT or webhooks. It features encrypted credential storage (AES-256-GCM), automatic backup scheduling, staleness detection, battery-aware operation, and a setup wizard. The architecture is primarily monolithic with the main daemon (iosbackupmachine.py) handling display, backup orchestration, network monitoring, and hardware integration, while separate modules handle sync management, crypto, config, and the web interface. The codebase is well-tested with unit tests covering fail-safes, resource bounds, and configuration migration, and it demonstrates strong engineering practices in areas like atomic file writes, log capping, and rate-limited progress reporting.
The LLM identified 5 files worth highlighting for reuse:
BindSupervisor is a class that manages HTTP listener addresses dynamically. It reconciles the live network interfaces against a configured bind list, starting/stopping listeners as interfaces appear or disappear. It logs transitions into and out of 'listening nowhere' states, making it suitable for devices with flaky or mobile network connections. This pattern is reusable in any multi-interface HTTP service that needs to adapt to network changes.
ConnectivityMonitor is a background thread that probes internet reachability (e.g., by HTTP GET to a known endpoint) and caches the result. It provides a non-blocking way to query connectivity status without delaying the request path. The cached state is updated on a configurable interval and can be consumed by other components. This is a clean, reusable pattern for any application that needs to show live network status without blocking.
This module provides a centralized configuration schema with versioned defaults, automatic migration from one config version to the next, and atomic save (tmp file + fsync + rename). It parses YAML, applies defaults for missing keys, and returns a list of warnings for user-facing messages. The migration pattern (N -> N+1 in place) is reusable in any application that needs to evolve a config file format without manual intervention.
This module handles encryption and decryption of remote sync credentials using AES-256-GCM with PBKDF2 key derivation. It stores encrypted data in a file (sync.enc) and provides a clean API for setting and retrieving credentials. The encryption pattern is isolated and reusable for any application needing to store secrets on disk with a passphrase-derived key.
TimestampedLog is a writer that creates timestamped log files in a specified directory, enforces a per-file size cap (e.g., 256KB), and supports reading the head and tail of a log without loading the whole file. It also includes a rotation mechanism that removes old logs. This is a reusable component for any daemon that needs to manage its own log files with size limits and avoid unbounded disk usage.