2.53
The project is in a healthy, maintained state
Bundles the Litestream VFS shared library for loading into SQLite connections.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Litestream GitHub release (latest by date) Status GitHub Docker Pulls

Litestream is a standalone disaster recovery tool for SQLite. It runs in the background, tracks changes in the SQLite write-ahead log, and replicates them incrementally to a local file or a supported remote storage backend.

If you need support or have ideas for improving Litestream, please visit GitHub Issues. Please visit the Litestream web site for installation instructions and documentation.

For optional service confinement, see the systemd hardening guide.

If you find this project interesting, please consider starring the project on GitHub.

File replica URLs

File replica URLs use URL path escaping. For example, file:///backups/daily%20backup refers to /backups/daily backup. Unicode paths are supported as well. Encode a literal percent sign as %25: a directory named /backups/daily%20backup is addressed by file:///backups/daily%2520backup.

Earlier versions wrote file replicas to the escaped form of the path, such as /backups/daily%20backup. If that directory exists and the decoded path does not, Litestream keeps using it and logs a warning with the command to rename it. If both directories exist, Litestream returns an error until one is merged or removed.

Source database changes

When Litestream begins replicating a database, it creates an internal _litestream_lock table in the source SQLite database. This is expected and safe to leave in place. Litestream uses the table to acquire SQLite's write lock while coordinating synchronization around WAL checkpoints. The writes occur in transactions that are rolled back, so Litestream does not leave rows in the table.

The table is part of the source database, not a separate table in the replica destination. Because the source schema is backed up, restored databases also contain it. Its creation changes the source database schema and can change its page count or bytes, so a database under Litestream should not be expected to remain byte-identical to its pre-Litestream state.

Do not drop _litestream_lock while Litestream is running. Synchronization around a checkpoint can fail until Litestream reinitializes the database. Restarting Litestream recreates the missing table automatically.

Stopping replication

litestream replicate attempts a graceful shutdown on SIGINT or SIGTERM. The top-level shutdown-timeout configuration setting limits the entire shutdown, including waiting for startup, an exec process, and closing databases and replicas. It defaults to 30s; set a longer duration when final replication needs more time. Invalid or nonpositive values produce a warning and use the default.

A second SIGINT or SIGTERM interrupts shutdown immediately. A timeout or interruption exits with an error because the final replica sync may be incomplete. This process-level bound also applies when a replica connection stops responding during startup. Cancellation of the calling context also starts a bounded graceful shutdown, using a fresh context for final replication. The existing shutdown-sync-timeout setting still controls each database's final replica sync retries within this overall limit. The process-level bound does not apply to callers of the Go library.

Contributing

We welcome bug reports, fixes, and patches! Please see our Contributing Guide for details on how to contribute.

Security

Please do not open a public issue for security vulnerabilities. Report them privately through GitHub's private vulnerability reporting, which keeps the report visible only to you and the maintainers until a fix is released. See our Security Policy for what to include and what to expect.

Acknowledgements

I want to give special thanks to individuals who invest much of their time and energy into the project to help make it better:

Huge thanks to fly.io for their support and for contributing credits for testing and development!