Backups and recovery¶
A backup script is easy. Knowing that the backup restores is a different exercise, and the gap between the two is where most self-hosted setups quietly live.
What is worth backing up¶
Not the whole box. Three categories, in descending order of how much it hurts to lose them:
- The memory database — facts, lessons, journal, state. Irreplaceable. Everything else can be rebuilt from source.
- The conversation archive — chunks and embeddings. Replaceable in principle (re-embedding is a batch job), but the raw transcripts underneath are not.
- Runtime configuration and credentials — the environment file, OAuth tokens, browser session state. Small, sensitive, and the thing that turns "restore" from an afternoon into ten minutes.
Application code is not on the list. It comes from a repository, and if it does not, that is the problem to fix first.
Schedule that survived¶
Daily at 03:00, keep seven. Weekly on Sunday, keep four. Compressed, that is 1–2 GB on this install — see the sizing notes for how that fits on a 40 GB disk.
The retention policy is the important half. "Keep everything" means running out of disk on a date nobody predicted, which is the failure mode the backups were supposed to prevent.
SQLite specifics that bite¶
Do not copy a live database with cp. A copy taken mid-write can be internally
inconsistent in ways that surface weeks later. Use the backup API, or VACUUM INTO, or at
minimum sqlite3 .backup. It is one line either way.
Watch out for accidental empty files. SQLite creates a database file on any open, including a read that fails with "no such table". Mistype a path and you have permanently created a 0-byte file that looks exactly like your real database from the next directory over. The habit that fixes it: always open read-only for reads, and always with an absolute path. Read-only fails loudly on a wrong path instead of silently creating a decoy.
That decoy is worse than a missing file, because a query against it returns empty rather than an error, and empty reads like "the data is gone".
The restore drill¶
Once, on purpose, before you need it:
- Take the newest archive to a scratch directory — not the live one.
- Extract, and run an integrity check on each database.
- Count rows in the tables that matter and compare against production.
- Point a throwaway instance at the restored files and ask it something only long-term memory would know.
Step four is the one that finds the real problems. The first time I ran it, the databases restored perfectly and the assistant still could not answer, because credentials lived outside the backup set and retrieval could not reach the embedding model. The backup was fine; the restore was not, and only the drill showed the difference.
Cheap habits that pay¶
- Keep one copy off the host. A snapshot on the same disk protects against your mistakes, not against the disk.
- Log every backup run to a table you can query, not to a log file you will never open.
- Alert on absence: a backup that stops running is silent by nature, which is exactly why it needs to be loud.
More notes from this build: avelina.ai.