Set up SQLite for production with WAL mode, safe transactions, and continuous Litestream backups to S3, plus a restore drill you can run today.
SQLite used to be the database you outgrew. Today it's a legitimate choice for many production apps, and the main reason is that the backup problem has been solved. This guide shows how to configure SQLite
safely and protect your data with continuous backups.
Configure SQLite for Production
Out of the box, SQLite is conservative. A few settings make a big difference. Run these when you open your connection:
PRAGMA journal_mode = WAL; PRAGMA busy_timeout = 5000; PRAGMA synchronous = NORMAL; PRAGMA foreign_keys = ON; WAL mode lets readers and the writer work at the same time, which is the biggest win for most web apps. busy_timeout tells SQLite to wait up to five seconds for a lock instead of failing immediately. foreign_keys is off by default and must be enabled on every connection.
Understand the Durability Trade-Off
In WAL mode, synchronous = NORMAL is faster and still protects against corruption. The trade-off is that a power loss can roll back the most recent committed transactions. If every write must survive a crash, use FULL and accept the speed cost.
Keep Write Transactions Short
SQLite allows only one writer at a time. Keep transactions small, and never call external APIs inside one. For writes, use BEGIN IMMEDIATE so SQLite takes the write lock up front. A deferred transaction that tries to upgrade mid-flight can fail with a busy error.
Continuous Backups with Litestream
Litestream streams WAL changes to S3-compatible storage in near real time. Install it, then describe your database in a config file:
- path: /var/lib/app/app.db replicas: - url: s3://my-bucket/app-db retention: 72h Run litestream replicate as a service next to your app. Your database then has a continuous replica you can restore from.
Restore Before You Need To
A backup you've never restored isn't a backup. Test the process on a copy of your database:
litestream restore -o app-restored.db s3://my-bucket/app-db Schedule this drill monthly. Check that the restored file opens and that your latest data is there.
Litestream or LiteFS?
Use Litestream when your main goal is backup and disaster recovery on a single primary server. If you need read replicas across several machines, look at LiteFS or a managed option such as Turso. Start simple, and add distribution only when your traffic demands it.
> Monitor What Matters
Watch the size of your WAL file, since a long-running reader can keep it from shrinking. Log busy errors so you can spot lock contention early. Check the timestamp of your replica's last successful sync, because a silent replication failure is the one you find out about too late.
When SQLite Is the Wrong Choice
SQLite fits read-heavy apps, single-server deployments, internal tools, and many SaaS products. It's a poor fit for workloads with many concurrent writers or for systems that must write across several regions at once. In those cases, PostgreSQL is still the safer choice.
Start Your Setup Today
Getting SQLite right comes down to a few settings, a continuous backup stream, and a regular restore drill. I put together a guide that walks through the full setup step by step, including a production checklist and a restore test you can run in your own environment, so you can ship with confidence.
Are you running SQLite in production today? Share your setup in the comments.
