Lesson 8 of 9 · 25m
Backups, Replication, and Surprising Production Use Cases
How to copy SQLite safely, where Litestream-style replication fits, why edge and high-read services use it, and the scale envelope that is larger than most people think.
SQLite shows up in places people associate with much heavier infrastructure: edge applications, embedded devices, analytics artifacts, mobile sync, desktop software, and even high-traffic websites. The pattern is not 'SQLite replaces Postgres.' The pattern is removing network coordination when data is local enough.
Safe backup starts with the backup API
The correct primitive copies pages consistently while respecting locks and journal state:
sqlite3 production.db ".backup 'backup-2026-11-29.db'"In application code, use the SQLite online backup API exposed by your language. Python exposes it as Connection.backup(target). It can run while the source is active because it participates in SQLite's locking protocol. File-system snapshots are valid only when they capture the database and journal state atomically or when the database is quiesced.
Replication is log shipping, not magic clustering
Tools such as Litestream continuously replicate SQLite by shipping WAL frames to object storage:
local app.db + WAL
|
v
Litestream -> S3-compatible object storage
|
v
restore point-in-time or warm replicaThis gives disaster recovery and read copies, not synchronous multi-primary writes. There is still one writer. That constraint is often acceptable for internal tools, small SaaS instances, per-tenant databases, edge nodes, and services where simplicity dominates.
The surprising scale envelope
A local SQLite database can serve very high read throughput because there is no network round trip. Reads from cache are memory-speed; writes are serialized but fast when transactions are small. Legitimate uses include a static-ish CMS, per-customer isolated databases, local-first mobile apps, embedded analytics files, control-plane metadata, and small-service outbox tables.
Know the exit criteria
SQLite is the wrong shape when you need many independent writers, online multi-region writes, very high concurrent write volume, row-level locking semantics, or central operational tooling that assumes a database server. It can still complement that architecture: edge nodes use SQLite locally and sync summaries to a central database.
Test restore, not backup success
A backup that has never been restored is a hypothesis. Automate restoration into a temporary file, run PRAGMA integrity_check, open the application, and execute representative queries. Verify schema version, row counts for critical tables, and restore duration because recovery time is part of the design.
Field notes
.backupis safer than copying files, but it still produces a point-in-time image; define your recovery point objective explicitly.- Object-storage replication depends on correct sequence handling; test failover before trusting it.
- One file per tenant is operationally simple until file count itself becomes the management problem.
- Beware write bursts from background jobs; a read-happy workload can still collapse under unbatched maintenance writes.
Was this lesson helpful?