by andrewaylett · 4mo ago · 0 comments
OUT="${i}.sql.zst"
PART="${OUT}.part"
sqlite3 -readonly "${i}" .dump | zstd --fast --rsyncable -v -o "${PART}" -
mv "${PART}" "${OUT}"
That doesn't block writers (when the writer uses WAL), and gives me a dump that's compressed well while also being easy to sync. My Home Assistant DB is 1.8GB, my dump is 286MB compressed, and I'd guess 90% of that is consistent from one day to the next.Neither does VACUUM INTO or ".backup" (which uses the backup API) or sqlite3_rsync or litestream.
Anyway, the sync-friendly output is the really important part for me, because it means I can point borg at the zstd-compressed file and it'll only need to store what's changed.
What's in the DB that makes the HA DB that big? You keep lots of historical time-series?
The SQLite backup script is part of my separate backup routine that predates HA's backups, and eventually makes it into a Borg backup hosted on rsync.net. Belt and braces.
I have only my own version of your SQLite backup. I suppose I shall learn the risks of this method with the first failure haha!