Backups
Hotaru backs up its two SQLite databases continuously with Litestream, which is built into the Docker image: hotaru.db, the app data, and durable.db, pi-durable’s state for the item pipeline (ADR-0002, pipeline.md). Every change is streamed to storage outside the server within about a second. Restoring is automatic: when the container starts and a database file doesn’t exist, Litestream restores its latest backup before the app starts.
Without LITESTREAM_REPLICA_URL, the app runs without backups and logs a warning on start.
Each database has its own replica: hotaru.db at LITESTREAM_REPLICA_URL, durable.db next to it at the same URL with -durable appended (for example …/litestream and …/litestream-durable). Two databases must never share one replica location.
durable.db can be lost without losing data that matters: the pipeline then marks the batches it was running as failed, and their items can be re-run (pipeline.md). Restore both files from about the same point in time when you can.
Where to back up
Litestream supports many replica types: S3 and S3-compatible storage (Backblaze B2, Cloudflare R2, MinIO, Hetzner Object Storage, …), SFTP, and more. Keep the backups outside the server, ideally with another provider or in another region, so one outage can’t take out both. Give Hotaru credentials of its own that can reach only its backup location.
Examples for LITESTREAM_REPLICA_URL:
s3://my-bucket/hotaru # with LITESTREAM_ACCESS_KEY_ID and LITESTREAM_SECRET_ACCESS_KEYsftp://hotaru-backup:<password>@backup.example.com/litestreamLitestream reads S3 credentials from LITESTREAM_ACCESS_KEY_ID and LITESTREAM_SECRET_ACCESS_KEY (or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY). An S3-compatible service other than AWS needs its endpoint in the URL: see Litestream’s guides. For an SFTP password, use only letters, digits and -, because it goes into a URL.
Set the variables, then restart the container. The log shows replicating to ….
Never point two installations at the same replica. A new installation with an empty volume restores whatever it finds there, and both would then write to it.
SFTP: pin the server’s host key
Without a pinned host key, Litestream accepts any server that answers at the SFTP address and logs sftp host key not verified. Get the key once from a machine you trust:
ssh-keyscan -t rsa backup.example.com 2>/dev/null | tee /dev/stderr | ssh-keygen -lf -Compare the fingerprint with the one your provider publishes. If it matches, copy the key part of the first line, without the host name, and set it:
LITESTREAM_SFTP_HOST_KEY=ssh-rsa AAAA…Litestream uses port 22 by default. Some servers offer only an RSA key there, so ask ssh-keyscan for that type.
Restore
Lost volume or new server (automatic)
- Deploy the app with the same
LITESTREAM_REPLICA_URLand credentials. - Make sure the
/datavolume is empty (a new volume is). - Start the container. The log shows
restore completed, and the app starts with the restored data.
Roll back to an earlier point in time
-
Stop the app.
-
In a one-off container with the same environment variables and the
/datavolume mounted, run:Terminal window mv /data/hotaru.db /data/hotaru.db.brokenrm -f /data/hotaru.db-wal /data/hotaru.db-shmlitestream restore -config /etc/litestream.yml -timestamp 2026-11-01T08:00:00Z /data/hotaru.dbThen
durable.dbthe same way, from the same point in time: move/data/durable.dbaside, delete its-waland-shmfiles, and restore/data/durable.dbwith the same-timestamp. -
Start the app again.
Copy a backup to your laptop
brew install benbjohnson/litestream/litestream # or see litestream.io/installlitestream restore -o ~/Desktop/hotaru-restore.db "<the same LITESTREAM_REPLICA_URL>"sqlite3 ~/Desktop/hotaru-restore.db "select count(*) from instance_settings;"Over SFTP, the laptop logs sftp host key not verified, because this command doesn’t pass the pinned key. Don’t leave the password in your shell history.
Delete the copy afterwards once it holds user data.
Tested
The docker job in CI tests a full cycle on every PR with a file replica: it starts the image with Litestream, writes a row, deletes the container and its data volume, starts a new container on an empty volume and checks that the row was restored.
Test your own setup now and then, for example after changing the storage or Litestream’s version: write something in the app, restore a copy to your laptop (above) and look for it.