Add Litestream continuous backup of the SQLite database
Task 47b27ccb: a litestream sidecar (litestream/litestream:0.5.17) in deploy/compose.yaml mounts the nestquest-db volume and replicates /var/lib/nestquest/nestquest.db over SFTP to the Synology NAS (10.60.1.50, /homes/Joshua/nestquest-backups), outside the Docker host. deploy/litestream.yml holds no secrets: the NAS host key is pinned and the dedicated SFTP private key is mounted read-only from the git-ignored deploy/litestream_key. api/README.md documents what runs, where it writes, key setup, and a high-level restore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+34
-2
@@ -36,5 +36,37 @@ which serves ``https://nestquest.cubecraftlabs.com`` (Let's Encrypt,
|
||||
auto-renewed, HTTP redirected to HTTPS) and forwards to the API box
|
||||
on port 8080 — so on that box set ``NESTQUEST_BIND_ADDRESS`` to its
|
||||
LAN address (``10.60.1.14``). Traefik only allows
|
||||
``/api/v1/panel`` from the Home Assistant host. Network separation,
|
||||
backup and restore are later Feature 17 tasks.
|
||||
``/api/v1/panel`` from the Home Assistant host. Network separation
|
||||
and the full restore runbook are later Feature 17 tasks.
|
||||
|
||||
## Continuous backup (Litestream)
|
||||
|
||||
Compose also runs a ``litestream`` sidecar
|
||||
(``litestream/litestream:0.5.17``, config ``deploy/litestream.yml``).
|
||||
It mounts the same ``nestquest-db`` volume and continuously replicates
|
||||
``/var/lib/nestquest/nestquest.db`` over SFTP to the Synology NAS
|
||||
``CubeCraft-SRVR1`` (``joshua@10.60.1.50``), directory
|
||||
``/volume1/homes/Joshua/nestquest-backups`` (``/homes/Joshua/...`` in
|
||||
the NAS's chrooted SFTP view) — so the backup is outside the Docker
|
||||
host and its volume. A snapshot is taken daily and a week of
|
||||
snapshots plus incremental changes is retained; the NAS host key is
|
||||
pinned in the config.
|
||||
|
||||
The SFTP login uses a dedicated keypair that lives only on the API
|
||||
box and is git-ignored. Create it once, before ``up``:
|
||||
|
||||
ssh-keygen -t ed25519 -N "" -C nestquest-litestream -f deploy/litestream_key
|
||||
|
||||
then append ``restrict `` + the contents of ``deploy/litestream_key.pub``
|
||||
to ``joshua@10.60.1.50:~/.ssh/authorized_keys``. Compose mounts the
|
||||
private key read-only at ``/etc/litestream/sftp_key``.
|
||||
|
||||
Check replication with
|
||||
``docker compose -f deploy/compose.yaml logs litestream`` or
|
||||
``docker compose -f deploy/compose.yaml exec litestream litestream ltx /var/lib/nestquest/nestquest.db``.
|
||||
To restore (high level): stop the ``api`` service, run
|
||||
``litestream restore -config /etc/litestream.yml -o <new path>
|
||||
/var/lib/nestquest/nestquest.db`` from a litestream container with the
|
||||
same mounts, verify the restored file, move it into place on the
|
||||
volume (removing any stale ``-wal``/``-shm`` files), and start ``api``
|
||||
again.
|
||||
Reference in New Issue
Block a user