Nojus Morkūnas

3 min read

Running my homelab with an AI agent

In May I wrote about the server in my room and the services I use most. Since then an AI agent has taken over most of the routine work, and this is how the server runs now.

Hermes does the routine work

I set up the first services by hand in 2022, before ChatGPT existed, and that's how I learned Docker and Docker Compose. These days most changes go through Hermes, an AI agent that runs on the server and that I talk to over Telegram. I ask it to deploy a service, write a script or find out why a container keeps restarting. It does most of the work.

Hermes can inspect anything on the server and recommend changes. It needs my explicit go-ahead before it does any of these:

  • Delete data. Removing Docker volumes or bind-mounted files, wiping a database or pruning unused Docker resources.
  • Change network access. Editing firewall rules, opening ports or changing router, DNS, reverse-proxy or tunnel settings that affect what's reachable.
  • Interfere with backups. Deleting or pruning snapshots, changing retention or what gets backed up and restoring over live data. The scheduled backups I've already approved keep running.
  • Deploy updates. It can check for new images and read release notes. Changing a running service's image, redeploying it or running a migration needs my approval.

Some of these I skip Hermes for and do myself over SSH.

I still keep an eye on the server myself. I check the monitoring and resource usage, and I look at containers by hand when something seems off.

Cron jobs

Hermes also runs most of the cron jobs, on schedules from every minute to once a month. A few examples:

JobSchedule
website uptime checksevery minute
Conatus demo resetevery 30 minutes
restic backupdaily at 02:00
update reviewfirst of the month

The demo reset keeps the public Conatus demo clean, whatever visitors do to it.

Backups

At 02:00 a script dumps the PostgreSQL databases of the running containers, archives their named volumes and sends those, my configs and my media to a Hetzner Storage Box with restic. It keeps 30 daily, 12 weekly and 12 monthly snapshots.

Backups only count if you can actually restore them successfully. In May I wrote about a PostgreSQL dump that didn't restore during a rebuild. The latest restore check, on 3 October, read 383 of the repository's 31,668 data packs, about 1%. It restored a database dump and a Home Assistant file to a scratch directory, compared their hashes with the originals and checked that the dump could be read. Both passed.

Alerts

Uptime Kuma watches the services on the server itself, with notifications through ntfy.

TwenteNotes runs on Railway, not on this server. I chose Railway so someone else would run the infrastructure. Then users started telling me the site wasn't loading. The frontend was failing with network errors when it fetched data, while Railway's status page showed no outage.

Since then, the server checks all my websites from the outside: morkunas.nl, platd.app, twentenotes.nl and useconatus.com. It requests each one every minute. For TwenteNotes it checks the homepage and the API's readiness endpoint separately, because the homepage can still load when the API can't reach its database. If a check fails twice in a row, I get a Telegram message, and another when the site recovers. Waiting for a second failure stops one slow request from setting it off. Hermes runs the schedule and sends the messages, but the checks themselves are plain Python and don't use any AI tokens.

If Railway keeps going down, I'll move TwenteNotes to the server in my room.

Updates

On the first of each month, a script lists every running image. Hermes then goes through the changelog of every project it can find one for and checks for breaking changes, database migrations and config changes before it sends me a recommendation on Telegram. During the review it isn't allowed to pull images, restart containers or change config.

Nothing updates until I approve it. When a release includes a database migration, the review suggests updating that service on its own after a fresh backup instead of updating everything at once.

The server does more than it did in May, and I do less of it by hand.