Image by Annie Ruygt
I’m Ben Johnson, and I work on Litestream at Fly.io. Litestream is the missing backup/restore system for SQLite. It’s free, open-source software that should run anywhere, and you can read more about it here.
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:
Wrap text Copy to clipboard $ sqlite3 SQLite version 3.50.4 2025-07-30 19:33:53 sqlite> .load litestream.so sqlite> .open file:///my.db?vfs=litestream
SQLite is now working from that remote database, defined by the Litestream backup files in the S3 path we configured. We can query it:
Wrap text Copy to clipboard sqlite> SELECT * FROM sandwich_ratings ORDER BY RANDOM() LIMIT 3 ; 22|Veggie Delight|New York|4 30|Meatball|Los Angeles|5 168|Chicken Shawarma Wrap|Detroit|5
This is Litestream VFS. It runs SQLite hot off an object storage URL. As long as you can load the shared library our tree builds for you, it’ll work in your application the same way it does in the SQLite shell.
Fun fact: we didn’t have to download the whole database to run this query. More about this in a bit.
Meanwhile, somewhere in prod, someone has it in for meatball subs and wants to knock them out of the bracket – oh, fuck:
... continue reading