Where to recover a SQLite write after a failure
| What fails | Earliest safe reply | Where to recover |
|---|---|---|
| App process crashes | Local commit | Reopen the writer’s database with its journal files intact. |
| Writer’s disk is lost | Server sync | Restore a retained version from the separate Litebackup server. |
| Only the backup server is lost | Local commit | The writer still has the order. The bucket also holds archived versions. |
| Both disks are lost | Bucket archive | Recover an archived version using bucket access and your recovery kit or passphrase. |
When can the app tell the customer the order is saved?
Reply after SQLite commits locally
Ordinary SQLite commits have no network wait. For power loss, the disk must survive and honor sync requests. Keep the database and its journal on persistent storage.
- WAL with FULL. SQLite syncs the WAL at each commit. Set
synchronous=FULLon the writing connection. - WAL with NORMAL. Recent commits can roll back after a power or OS failure.
- DELETE journal. SQLite recommends
synchronous=EXTRAfor power-loss durability. SQLite sync settings.
Wait for a copy on the backup server
Call databases.sync(name, { durability: "server" }) after commit on the writer, as above. A timeout leaves server durability unknown. Retry the wait. Reuse the same order ID if the write itself is retried. After lease expiry, a standby takes over from the latest version the server received. Restore a retained version or set up writer failover.
Wait for a copy in the bucket
Save the syncedServer.version returned by the sync. Wait until databases.get(name) reports syncedCloud.version at least that high.
The archive delay defaults to 15 minutes, and uploads can take longer. For a separate, unregistered export, a foreground backup with durability set to cloud waits for archival. SDK durability options · Recover the backup server.
Install
Install the server, then join the app machine and register its database for continuous backup.