TOOLS Calculate exact WireGuard & Tailscale MTU, TCP MSS clamps, and CIDR ranges in seconds Open MTU & Subnet Tool →
Web & Backend · 9 Min Read · By Radz

Running SQLite in Production with WAL Mode, Busy Timeouts, and Safe Backups

How to configure SQLite Write-Ahead Logging (WAL), synchronous=NORMAL, busy_timeout, and atomic online snapshots without SQLITE_BUSY lock errors.

Author: Radz (Systems & Network Engineering) Published: 2026-11-21 Updated: 2026-11-23

For single-node web services, internal admin portals, release catalogs, and desktop/mobile applications, SQLite eliminates network hop latency and external database administration. Most teams hit trouble only because SQLite ships in legacy rollback-journal mode (DELETE), where any writer locks out concurrent readers.

1. Essential Connection Pragmas on Startup

Enable Write-Ahead Logging (WAL) once per database file and configure per-connection timeouts on every new handle:

PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA busy_timeout = 5000;
PRAGMA foreign_keys = ON;
PRAGMA cache_size = -16000; -- ~16 MB negative KiB page cache

2. Never Back Up a Live WAL Database with Plain cp

Copying only app.db while omitting app.db-wal leaves recent committed transactions behind and risks torn page reads. Always use SQLite's online backup API or VACUUM INTO:

# Safe online snapshot while traffic continues running
sqlite3 /var/lib/app/app.db "VACUUM INTO '/var/backups/app-snapshot-20261123.db';"

VACUUM INTO writes a clean, compacted, standalone database file atomically without blocking ongoing readers.

3. Managing WAL Growth & Periodic Checkpointing

Under steady continuous read traffic, a long-running read transaction can prevent SQLite's automatic checkpoint (PRAGMA wal_autocheckpoint = 1000) from resetting the -wal file back to zero, occasionally causing multi-hundred-megabyte WAL growth. Guard against runaway WAL growth by:

Written by Radz · OrangeVPN Engineering

Independent systems architect publishing field-tested guides on WireGuard/Tailscale networking, Linux security, and Android automation. Notice an errata or want to share a question?