Again with the sandwiches: assume we’ve got a SQLite database of sandwich ratings, and we’ve backed it up with Litestream to an S3 bucket. Now, on our local host, load up AWS credentials and an S3 path into our environment. Open SQLite and:
Overview
Litestream VFS is a new SQLite plugin that enables querying databases directly from S3-compatible object storage without downloading the entire database. Built on the LTX file format, it supports instant point-in-time recovery (PITR) through SQL pragmas and can function as a near-realtime read replica by polling backup files, all while maintaining Litestream's philosophy of working alongside unmodified SQLite applications.
What You'll Learn
How to query a remote SQLite database directly from S3 using Litestream VFS without downloading the entire database
How to perform instant point-in-time recovery (PITR) using SQL pragmas with relative or absolute timestamps
Why LTX compaction drastically accelerates database restores by skipping redundant page versions
How Litestream VFS implements a near-realtime read replica by polling S3 backup files
How the SQLite VFS plugin interface abstracts the OS layer to enable remote page reads via S3 Range requests
Prerequisites & Requirements
- Basic understanding of SQLite databases and SQL queries
- Familiarity with object storage concepts (S3 buckets, file paths)
- Litestream v0.5 or later configured with S3-compatible object storage
- AWS credentials and S3 path configured in environment
- Understanding of database backup and restore concepts(optional)
Key Questions Answered
How does Litestream VFS let you query a SQLite database without downloading the whole file?
What is LTX compaction and how does it speed up Litestream restores?
How do you perform point-in-time recovery with Litestream VFS?
Does Litestream VFS replace SQLite or require application changes?
How does Litestream's tiered backup compaction system work?
Can Litestream VFS work as a near-realtime database replica?
What is the SQLite VFS interface and how does Litestream use it?
What is LTX and how does it relate to Litestream and LiteFS?
Key Statistics & Figures
Technologies & Tools
Some links below are affiliate links. We may earn a commission if you make a purchase.
Key Actionable Insights
1Use Litestream VFS for quick ad-hoc queries against production data without SSHing into production servers. Load the shared library, point it at your S3 backup path, and run SQL queries directly from your development machine. This eliminates the need for full database restores just to check a few values.Particularly useful for debugging production issues or running sanity checks where you need to query live data without touching production infrastructure.
2Leverage PITR pragmas with relative timestamps like '5 minutes ago' for instant disaster recovery verification. When accidental data modifications occur (e.g., missing WHERE clause on UPDATE/DELETE), you can immediately query the pre-disaster state to assess damage and plan recovery.This is instantaneous compared to traditional full database restores, making it practical for incident response and data auditing workflows.
3Understand that Litestream VFS handles only the read side of SQLite operations. The standard Litestream Unix daemon still manages writes and backups. This separation means you can adopt VFS for read-only use cases (analytics, debugging, replicas) without changing your write path at all.This architectural decision means VFS adoption is incremental — you can start using it alongside your existing Litestream setup without any migration risk.
4Take advantage of LTX compaction's tiered architecture when planning backup retention policies. The L0 layer captures changes every second but compacts quickly to L1 (30-second intervals), while higher levels use progressively larger time windows up to 1 hour. Configure retention based on your PITR precision requirements at different time horizons.The tiered approach means you get second-level granularity for recent changes while keeping storage costs manageable for longer-term retention through automatic compaction.
5Consider using Litestream VFS as a near-realtime read replica by having it poll the S3 path for L0 updates. Since Litestream backs up once per second, the VFS can incrementally update its page index to stay current — without streaming the entire database to the replica machine.This is especially valuable for ephemeral or edge compute environments where spinning up lightweight read replicas quickly matters more than having a full local copy.