
Litestream
SQLite streaming replication and disaster recovery for single servers
Replaces —
Who it's for
Litestream adds continuous cloud backup to any SQLite-backed web app without modifying a line of application code. A developer running a low-to-medium traffic site on a single VPS can point Litestream at the database file and an S3 bucket, and every committed transaction is off-site within seconds. Disaster recovery means restoring the snapshot and replaying the WAL, not restoring from a nightly dump and losing hours of writes.
If your app already runs on a managed database like Postgres or MySQL, Litestream adds nothing. It is specifically for applications that write to a SQLite file on disk.
When a codebase uses SQLite and the team faces pressure to switch to a client-server database, Litestream is the counter-argument. It closes the durability gap that makes SQLite seem unsuitable for production without requiring a migration, schema changes, or a new database driver.
If the application genuinely needs concurrent writes from multiple processes or servers, SQLite's single-writer model is the actual constraint and Litestream does not change it.
Litestream is documented for Kubernetes sidecar deployments, where it runs as a second container in a pod alongside the application container. The SQLite file lives on a shared volume; Litestream replicates from that volume to object storage. On pod replacement, the new pod restores from the replica before the application starts.
Pods that need to scale horizontally and all write to the same dataset cannot use this pattern. SQLite's locking model prevents multiple writers, and Litestream does not add distributed write coordination.
The problem
SQLite is the default database for embedded apps, scripts, and single-server web services because it requires no separate server process and produces a single file on disk. But that simplicity creates a reliability gap in production: SQLite's write-ahead log is a local file, so a disk failure, an OS crash, or a missed checkpoint means you lose any transactions that were not yet checkpointed to the main database file. The standard workaround is to move off SQLite and onto a managed database like Postgres or MySQL, which adds a separate server to operate, a network round-trip to every query, and a monthly bill even for small traffic. For apps where SQLite's performance characteristics are a good fit and a single write process is acceptable, that migration is all cost and no benefit.
How it works
Captures SQLite's write-ahead log frames incrementally and ships them to the configured object storage backend within seconds. Each WAL frame represents a committed transaction, so replay from a snapshot plus the replicated WAL restores the database to any point since replication began.
Supports Amazon S3, Google Cloud Storage, Azure Blob Storage, SFTP, and local file paths as replica destinations. Configuration is one YAML file with the backend credentials and the replica URL; switching backends requires no application changes.
Litestream communicates with SQLite exclusively through the SQLite API. It attaches to the existing database file and takes over WAL checkpoint coordination through a lightweight internal lock table. The application continues reading and writing the same file path unchanged.
On SIGINT or SIGTERM, Litestream attempts to complete a final WAL sync before exiting. The `shutdown-timeout` setting (default 30 seconds) limits the entire shutdown sequence, including any in-flight replication, preventing data loss at process stop. A second signal interrupts shutdown immediately.
Available as a Docker image (`litestream/litestream`) and documented for Kubernetes sidecar deployments. Runs as a separate process alongside the application container, sharing the SQLite file path through a mounted volume, without any changes to how the application opens or writes the database.
Features
- Continuous WAL replication
- Multiple storage backends
- Zero code changes required
- Graceful shutdown with configurable timeout
- Docker and Kubernetes compatible
How to install
Deploy Litestream as a server process to replicate your SQLite database to object storage.
docker run litestream/litestream replicate /path/to/db.sqlite s3://bucketname/db.sqliteRecommended for this setup
Strengths
- No application code changes: Because Litestream operates at the SQLite file level via the WAL, existing applications that write to a SQLite file get continuous replication with only a configuration file and a sidecar process added. There is no SDK to include, no connection string to change, and no migration script to run.
- Apache-2.0 license: Apache-2.0 permits commercial use, modification, and distribution without copyleft requirements. You can run Litestream inside a commercial product, modify it, and ship it as part of a larger service without licensing restrictions or source disclosure requirements.
- Single-binary deployment with near-zero cost: The replication target is standard object storage, which runs at pennies per day for most SQLite databases. Litestream itself is a single static Go binary with no runtime dependencies beyond object storage credentials. The total cost of disaster recovery is the storage bill with no additional infrastructure.
- Transaction-level recovery granularity: Recovery is not limited to daily snapshots. Because Litestream replicates individual WAL frames, you can restore to the exact state of any committed transaction since replication began, not just the last scheduled backup window.
Trade-offs
- Single-writer constraint: Litestream replicates SQLite's WAL but does not add multi-node write capability. If your application needs multiple concurrent writers from different servers, SQLite's single-writer model and Litestream's replication architecture are not the right fit. At that point a client-server database is the correct choice.
- Beta status: The repository carries a beta status badge. The replication protocol and configuration format have been stable across the v0.3.x and v0.5.x lines, but production deployments should treat breaking changes between major versions as possible and review the changelog before upgrading.
- Modifies the source database schema: Litestream creates a `_litestream_lock` table in the source SQLite database on first connection. This changes the schema and may alter the page count and byte size of the database file. A database under Litestream should not be expected to remain byte-identical to its pre-Litestream state, which can affect checksum-based integrity tests.
Tech stack
FAQ
Litestream does continuous streaming replication. It captures each SQLite WAL frame as it is written and ships it to the replica destination in near real time, not on a schedule. Recovery is to the most recent replicated transaction, not the last scheduled snapshot.
Litestream supports Amazon S3, Google Cloud Storage, Azure Blob Storage, SFTP, and local file paths. Configuration is in a single YAML file with the backend credentials and replica URL. Multiple replicas can be configured to write to different destinations simultaneously.
No. Litestream communicates with SQLite only through the SQLite API and never writes directly to the database file outside of coordinating WAL checkpoints through a lock table. The README explicitly states it will not corrupt the database. It does create an internal `_litestream_lock` table on first use, which changes the schema but leaves no persistent data.
Litestream listens for SIGINT and SIGTERM and attempts a graceful shutdown by completing a final WAL sync before exiting. The `shutdown-timeout` setting (default 30 seconds) caps the entire shutdown sequence. A second signal interrupts shutdown immediately, which may leave the final replica sync incomplete and exits with an error.
Yes. Litestream is licensed under Apache-2.0, which permits commercial use, modification, and distribution without copyleft requirements. You can run it in a commercial product or infrastructure without licensing fees or source disclosure obligations.