Spent most of today trying to get a clean backup of our database.sqlite and I’m stuck, so figuring I’d ask before I go down the WAL rabbit hole blind.
Quick context: self-hosted, Docker Compose + Traefik, single container (not queue mode), n8n version 1.123.5. Database’s about 3.5GB, still on the default rollback journal mode, not WAL. Instance runs two clients’ workflows (tagged), fairly high Pipedrive/Calendly/CloudTalk/WebinarJam webhook volume during the day. We already back up the workflows themselves via the API on a cron, but I want an actual full database.sqlite snapshot too — credentials, encryption key, executions, the works in case the VPS disappears entirely.
Started simple: sqlite3 database.sqlite ".backup 'out.sqlite'". Straight up Error: database is locked, first try.
Fine, added .timeout — tried 10s, 30s, 60s. Still locked, every time, even after waiting the full minute.
Then wrote a small retry loop, 10 attempts, 30s apart, so like 5-8 minutes of just hammering at it. Not one attempt got through.
At that point I figured it had to be workflow traffic, so I pulled the list of active workflows (40 of them, across both clients), deactivated literally all of them through the API, waited, and ran the retry loop again for another 6 minutes with zero workflows active. Still locked. Every attempt. Reactivated everything after (double checked they all came back, they did).
Last thing I tried, kind of out of ideas at that point is docker pause’d the whole container and tried .backup while it was completely frozen. Failed instantly, before I even unpaused. Which honestly surprised me. I assumed a fully frozen container = zero write activity = no lock. Best guess now is that the file lock belongs to whatever connection was already holding it, and freezing the process doesn’t release it, it just freezes it mid-hold — so if the writer happened to be mid-transaction the moment I paused, that lock just sits there stuck for the whole pause. If that’s right then it’s basically down to luck whether a pause catches it idle or not, and today I never got lucky.
Went through a full day of docker logs after that trying to find whatever’s writing this much, filtered out all the bot/webhook noise. Found basically nothing — one single “Pruning old insights data” line, once, all day. Doesn’t line up with a lock that’s held for 45+ minutes straight across several separate tests. Checked recent executions through the API too and saw legit Pipedrive-webhook bursts every ~5s or so, but that can’t be it either since the lock didn’t budge even with everything deactivated.
So at this point whatever’s writing isn’t logging anything and isn’t tied to any workflow I can find, which is a bit unsettling.
A few things I’m hoping someone here has actually dealt with:
- Anyone seen the db stay locked like this with literally zero active workflows? Any idea what internal n8n process could be holding a write open without printing anything — insights collection, pruning, license check-ins, connection pool stuff, anything?
- Has anyone switched a live, busy production instance over to WAL (
PRAGMA journal_mode=WAL;) without taking it down? Does n8n ever quietly reset the journal mode back on its own restart? Any issues with the -wal file just growing forever if checkpoints don’t happen? - And honestly — at what point do people here just give up on SQLite and move to Postgres instead of fighting it? Is there some rough size/traffic line where that’s obviously the right call?
Not trying to take the instance down to fix this, it’s running a live sales pipeline, so any pointers from people who’ve actually hit this welcome.