"""Safe backup/restore for the soc-ai local store (``soc-ai backup`` / ``restore``). The operator's store is months of investigations, audit history, runbooks, and config overrides in one SQLite file — with WAL journaling, so a naive ``cp`` of a live database can capture a torn page set. This module snapshots it SAFELY: the stdlib :meth:`sqlite3.Connection.backup` API copies a consistent, committed view through a second connection and honors WAL, so **backups are safe while the app is running**. Archive layout (``soc-ai-backup-.tar.gz``):: manifest.json # schema head, app version, created_at, source dir data/soc-ai.db # the consistent DB snapshot data/ # app-owned files next to the DB (see below) caches/