Guide
Operation and backup
Updating, pinning a state, the nightly backup with backup.sh, restoring and faults.
Updating
A new state arises when you push to main: "Check" turns green, "Image"
puts a new latest into the registry. On the VPS:
docker compose -f /opt/henniokf/docker/compose.vps.yml up -d
Compose pulls the newest image and restarts the container if it changed.
The login to the registry from the installation still applies. The data in
the root directory stays as it is. Without pull_policy: always Docker
would take an old, locally kept latest.
Afterwards read the commit on /status under "Version". It is the same as
in the last green run of "Image":
gh run list --workflow Image --limit 3
When you need git pull: only if docker/compose.vps.yml,
docker/vps.env.example or docker/backup.sh change. Then
git -C /opt/henniokf pull, add a new variable to docker/.env and start
again. Such a change stands in docs/log.md.
Pinning a state
Every image also carries the short commit as a tag. In docker/.env:
HENNIOKF_IMAGE=ghcr.io/arpablo/henniokf:<commit>
Then start again. Back to the newest state: remove the line and start once more.
Without GitHub Actions
If GitHub Actions fails, build the image on the VPS from the clone:
cd /opt/henniokf && git pull && docker/build.sh -t ghcr.io/arpablo/henniokf:latest
docker compose -f /opt/henniokf/docker/compose.vps.yml up -d --pull never
--pull never keeps Compose from replacing the image you just built with
the one from the registry. The build needs memory and takes minutes.
The backup
The image can be pulled again at any time, the data in the root directory
cannot. In phase 1 that is users/ with the accounts database and the
session secret. docker/backup.sh backs them up.
- It copies every SQLite database inside the running container with
the backup function of SQLite, through
better-sqlite3. A plain copy of a running database can be unusable. - It checks every copy with
integrity_check. - It packs everything into
/srv/henniokf-backup/henniokf-<time>.tar.gzand checks that the archive is readable. - It deletes archives older than 14 days.
- Optionally it copies the archive with
rsyncto a second place.
The application keeps running meanwhile. The script only reads the root directory and ends without error only if the archive is complete and every check passed.
Set it up once, as root, one line for cron:
echo '17 3 * * * root /opt/henniokf/docker/backup.sh >> /var/log/henniokf-backup.log 2>&1' > /etc/cron.d/henniokf-backup
From then on it runs every night at 3:17. Give every project on the same VPS another minute. By hand, for example to try it:
/opt/henniokf/docker/backup.sh
| Variable | Default | What for |
|---|---|---|
HENNIOKF_DATA | /srv/henniokf | the root directory |
BACKUP_DIR | /srv/henniokf-backup | folder for the archives |
BACKUP_DAYS | 14 | archives stay this many days |
BACKUP_CONTAINER | henniokf | the running container, - for a computer without a container |
BACKUP_APP | /opt/henniokf | the clone, only with BACKUP_CONTAINER=- |
BACKUP_COPY_TO | empty | optionally a target for rsync, such as <user>@<host>:<path>/ |
A backup on the same VPS protects against own mistakes, not against losing
the VPS. That is what BACKUP_COPY_TO is for.
What is backed up stands at the top of the script in two lists:
PARTS=(users)
DATABASES=(users/users.sqlite)
With the later phases more parts come in, such as records and jobs. They
go into both lists, see Recipes for extending.
Whatever is listed and missing the script skips.
Restoring
docker compose -f /opt/henniokf/docker/compose.vps.yml stop
tar -xzf <archive> -C /srv/henniokf && chown -R 1000:1000 /srv/henniokf
docker compose -f /opt/henniokf/docker/compose.vps.yml start
Useful commands
docker ps # which containers run
docker logs --tail 50 henniokf # the last lines of the log
docker image prune -f # delete old, unused images
docker exec -it henniokf sh # a shell in the container
Faults
| What you see | Cause | What helps |
|---|---|---|
docker login or pulling the image fails | the token is fine-grained, lacks read:packages, or expired | a token (classic) with only read:packages |
network traefik-proxy declared as external, but could not be found | the network of Traefik has another name | the name in TRAEFIK_NETWORK |
| invalid certificate | the DNS does not point to the VPS yet, or TRAEFIK_CERTRESOLVER is wrong | check with dig, read the log of Traefik |
| 404 from Traefik | HENNIOKF_HOST or TRAEFIK_ENTRYPOINT is wrong | correct docker/.env, start again |
| 502 right after the start | the container is not ready yet | wait a few seconds |
/status reports that a directory cannot be created | the root directory does not belong to UID 1000 | chown -R 1000:1000 /srv/henniokf |
| the first admin cannot be created | HENNIOKF_SYNC_TOKEN empty or typed differently | check the value in docker/.env, start again |
/status shows the old commit after updating | "Image" is not finished or was red | look on GitHub, then start again |
| the page does not load in a hotel network, in the mobile network it does | a web filter blocks the new domain | work over the mobile network |
| the backup reports that copying the databases in the container failed | the container does not run or has another name | docker ps, otherwise set BACKUP_CONTAINER |
Next: In a web console.