Backups
Everything Homelander stores is in one SQLite file (DATABASE_PATH): people, houses, chats, labels, the site, pages with their files, the data space and module data. A backup is one copy of that file, so a restore brings everything back at once.
Design: database backups.
How it works
- The service makes the backups itself, on a schedule set in the admin panel (Settings → Backups). It needs no cron, so it works the same on Railway, in Docker and on a small Linux box.
- Each backup is a consistent snapshot of the live database. It uses
VACUUM INTO, SQLite's online copy, so the service keeps running while it is taken. The copy is checked withPRAGMA integrity_checkbefore it gets its final name. A file namedhomelander-*.dborhomelander-*.db.ageis always a complete, checked backup. - Backups go to the local folder
BACKUP_DIR. By default that isbackups/next to the database (/data/backupson Railway). - With S3 storage set up, every encrypted backup is then copied to a bucket too.
- With Telegram set up, the bot sends the encrypted file to the chats and people with a chosen label: every backup, once a day or once a week.
- If a copy to S3 or Telegram fails, the run is marked partly done: the local backup is still there, and the next run tries again.
- History: the newest backup of each of the last 7 days, 4 weeks and 6 months is kept (you can change the numbers), in the folder and in the bucket alike. The newest backup is never deleted.
- Every run is listed on the Backups page and in the audit log. The Overview page warns when backups are off, when none was written for two periods, or when the last one reached only some storages.
- New installations take daily backups at 03:00 UTC, unencrypted, until an admin changes that.
Encryption
Create the key once, on the Backups page, with Create encryption key:
- Your browser makes an age key pair.
- The private key (
AGE-SECRET-KEY-1…) is shown once. Copy it or download the key file, and keep it outside the server, for example in a password manager. - Only the public key (
age1…) goes to the server. From then on every backup is a.db.agefile that only the private key can open.
The server never has the private key. A copy of a backup that leaks, or even the server itself, does not expose the data in old backups. Without the private key the backups cannot be restored. Use Check my key now and then to make sure the key you saved still matches; the check happens in your browser.
Have your own age key? Choose "I have my own age key" and paste its public key. Without a browser, homelander backup keygen prints a pair.
Settings
| Where | What |
|---|---|
| Admin panel | on/off, how often (6, 12 or 24 hours), the hour (UTC), how many backups to keep, the encryption key, the Telegram label and how often files go there |
BACKUP_DIR | the local folder; default backups/ next to DATABASE_PATH |
BACKUP_DISABLED=true | no scheduled backups whatever the panel says (e.g. a staging copy of production data). "Back up now" and the CLI still work. |
BACKUP_S3_* | the S3 storage backups are copied to; see S3 storage. The panel shows it read-only, can pause it, and tests the connection. |
BACKUP_AGE_IDENTITY | the private key, only while restoring on a host where you can set nothing but variables (Railway). Remove it right after. |
Keep a copy off the disk
A folder on the same disk as the database survives deletions and bad updates, but not losing the disk. Keep another copy elsewhere:
- Any host: set up S3 storage, or Telegram if you have no bucket.
- Docker / Linux box: you can also mount another disk, a USB stick or a NAS share and set
BACKUP_DIRto it, or copy the folder elsewhere with your usual tools (rsync, restic, …). Encrypted backups are safe to copy anywhere. - Railway: keep Railway's own volume backups on as well (see deploy-railway.md step 6).
S3 storage
Any S3-compatible storage works: Cloudflare R2, Backblaze B2, AWS S3, MinIO, and others. After each backup is written to the local folder, it is uploaded to the bucket, and old copies there are removed by the same history rules.
Only encrypted backups are sent. Create the encryption key on the Backups page first. Without a key, runs are marked partly done and nothing leaves the server.
Everything is set with variables on the server, not in the panel. A restore on a new server then needs nothing but the same variables, and nobody with an admin session can redirect the backups to another bucket.
| Variable | What |
|---|---|
BACKUP_S3_ENDPOINT | the storage's address, without the bucket |
BACKUP_S3_BUCKET | the bucket |
BACKUP_S3_PREFIX | optional folder in the bucket, such as homelander/ |
BACKUP_S3_REGION | optional; by default the storage is asked |
BACKUP_S3_PATH_STYLE | auto (default), path (https://host/bucket) or virtual (https://bucket.host) |
BACKUP_S3_ACCESS_KEY_ID, BACKUP_S3_SECRET_ACCESS_KEY | the access key |
The endpoint, bucket and both keys are needed once any of them is set; the service does not start with half a setup. Then open Settings → Backups → Storage and press Test connection: it writes, lists and deletes a small file, which checks every permission backups need. The same tab can pause the uploads.
Examples (the values in angle brackets are yours):
| Storage | BACKUP_S3_ENDPOINT | BACKUP_S3_REGION |
|---|---|---|
| Cloudflare R2 | https://<account id>.r2.cloudflarestorage.com | auto |
| Backblaze B2 | https://s3.<region>.backblazeb2.com | <region>, e.g. eu-central-003 |
| AWS S3 | https://s3.<region>.amazonaws.com | <region> |
| MinIO | http://<host>:9000 | leave empty; set BACKUP_S3_PATH_STYLE=path |
Keep the bucket private, and give the service a key that can reach only that bucket (R2: an API token with "Object Read & Write" for the one bucket; B2: an application key restricted to the bucket; AWS: a policy with s3:PutObject, s3:GetObject, s3:DeleteObject and s3:ListBucket on the bucket). The service deletes old copies, so the key needs delete rights. For protection against a compromised server deleting the copies too, turn on the bucket's versioning or object lock with a lifecycle rule; the service does not need to know about it.
Telegram
The bot can send each encrypted backup as a file to Telegram. Nothing to set on the server: open Settings → Backups → Storage, pick a label under Send to and how often, and save.
- The file goes to every chat, forum topic and person with that label, the same places a message to that label reaches. The best receiver is a separate label (say
backups) on a private group of the owners, or on the owners themselves; a person gets the file only with a linked Telegram account. - Only encrypted backups are sent. Without an encryption key, nothing goes to Telegram and the run is marked partly done.
- How often: every backup, the first backup of a UTC day, or the first of a week (Monday to Sunday). If sending fails, the next backup of the same day or week tries again.
- Telegram takes files from bots up to 50 MB. A bigger backup is not sent (the run says so); use S3 for it. A community database is usually far smaller.
- The bot does not delete old files (Telegram does not let bots delete old messages). Delete them by hand if the chat gets long; nothing on the server depends on them.
- The Storage tab shows how many places the label reaches now and when the last file was sent.
To restore from Telegram, download the file from the chat and use it with homelander restore --from <file> like any other backup.
Commands
The same binary runs them. They need only DATABASE_PATH (and BACKUP_DIR and the BACKUP_S3_* variables), not the service's other secrets, and they work in the distroless image, which has no shell.
homelander backup # one backup now with the stored settings; prints the file name
homelander backup keygen # a new age key pair
homelander backup list # the backups in the local folder and in S3
homelander restore --from <file | s3:<name> | s3:latest> [--identity <key file>] --yesRestore
homelander restore:
- downloads the backup first if it is in S3 (
--from s3:homelander-….db.age, ors3:latestfor the newest), using theBACKUP_S3_*variables; - decrypts the backup if it is encrypted (
--identity <file>, orBACKUP_AGE_IDENTITY); - checks it with
PRAGMA integrity_check, and checks that it was made by this version or an older one; - moves the current database and its
-wal/-shmfiles tohomelander.db.before-restore-<time>(nothing is deleted); - puts the backup in place.
On the next start the service runs migrations forward as usual. If something is wrong, stop the service and put the before-restore file back.
Stop the service first. A running service keeps writing to the old database.
Docker
docker compose stop homelander
docker compose run --rm homelander restore --from /data/backups/homelander-20261128T030000Z.db.age --identity /keys/homelander-backup-key.txt --yes
docker compose start homelanderMount the key file read-only for that one run (for example -v ~/homelander-backup-key.txt:/keys/homelander-backup-key.txt:ro with docker run), and do not leave it on the server.
Linux box (systemd)
sudo systemctl stop homelander
sudo -u homelander env DATABASE_PATH=/var/lib/homelander/homelander.db homelander restore --from /var/lib/homelander/backups/homelander-20261128T030000Z.db.age --identity ~/homelander-backup-key.txt --yes
sudo systemctl start homelanderRailway
The service cannot be stopped while a command runs in it, so the restore runs as the service for one deploy:
- Service → Variables: add
BACKUP_AGE_IDENTITYwith the contents of your key file (only for an encrypted backup). - Service → Settings → Deploy → Custom Start Command:
/homelander restore --from /data/backups/homelander-20261128T030000Z.db.age --yes. The file names are on the Backups page. - Deploy, and wait for the log line
restored … start the service to finish. The command then exits, so Railway shows the deployment as stopped or failed (no health check). That is expected. - Remove the start command and the
BACKUP_AGE_IDENTITYvariable, and deploy again. The service starts on the restored database.
A new server, from S3
When the disk is gone, start from an empty data folder with the same BACKUP_S3_* variables and the private key. (No S3? Download the newest file from Telegram instead and use --from <file>.)
homelander backup list
homelander restore --from s3:latest --identity homelander-backup-key.txt --yesThen start the service as usual. On Docker, run the two commands with docker compose run --rm homelander … before docker compose up -d. On Railway, use the start command /homelander restore --from s3:latest --yes with BACKUP_AGE_IDENTITY, as above.
Checking a backup without restoring
With the sqlite3 and age tools on your computer:
age --decrypt -i homelander-backup-key.txt -o copy.db homelander-20261128T030000Z.db.age
sqlite3 copy.db "PRAGMA integrity_check; SELECT count(*) FROM users;"