My Deploy Script Deployed My Backup
My new auto-deploy script found a gitignored backup and shipped a June config to production. The recovery took the core host from 32 containers to 9. The fix was a change of scope, and the same class of bug came back twice anyway.
On 2026-08-25 I installed a script that deploys my Docker hosts when a change merges to main. Seven minutes later it redeployed my core host from a two-month-old config.
What the script did
Every 15 minutes it fast-forwards the host's Git clone and brings each compose project in line with the repo. To find those projects, the first version ran find over the clone.
Next to the live compose file sat a _backups directory: dated snapshots of older configs, gitignored, kept for bad days. find has no idea what Git ignores. It found a compose file from June 17 and ran docker compose up -d from it.
That June file predated the reverse proxy's port mapping for Git over SSH. The proxy was recreated without it. Everything behind it stopped answering for about 30 seconds. Git SSH stayed down for every host, so every git fetch failed. The loop that would have deployed a fix was the thing that was broken.
The recovery made it worse
I was doing this work with Claude Code, and the agent noticed the outage mid-change. Its recovery was the obvious move: bring the stack up from the canonical compose file with --remove-orphans.
Compose had already adopted the live project from the backup path, before any of this started, and nobody had checked. docker compose ls listed the project's config file as the June snapshot. So "orphan" meant "any container the June file doesn't mention", which was most of the stack. Those containers were removed, and then the run aborted on a container name conflict. Two compose projects on that host declared the same monitoring containers, and only one project can hold a name.
Running containers went from 32 to 9. Stopping the second project freed the names, and a clean redeploy from the canonical file brought all 32 back. The incident record puts this second outage at about 20 minutes. No data was lost and nothing needed a reboot. The same flag had also deleted two profile-gated services, and no later redeploy brought them back on its own.
Three signals that looked authoritative
Files on disk, the project's recorded config path, and a flag that sounded like housekeeping. All three were wrong. The repo is the source of truth, so the fix made it the only one:
scope git ls-files: anything gitignored cannot deploy
project identity refuse if the live project runs from an untracked file
validate all one invalid stack refuses the run before anything changes
.nodeploy templates and migrated stacks never deploy on this host
--remove-orphans gone from the script entirely
Auto-deploy went off everywhere, then came back one host at a time after a pull-only dry run. Three compose hosts deploy on merge. The core host stays pull-only on purpose: it runs the reverse proxy and SSO, and breaking those removes the route you would use to fix them. The Git host stays pull-only too, because Gitea deploying Gitea is a bootstrap loop.
One gap is still open: docker compose up -d is not atomic within a single stack, so a container that fails mid-pull can leave that stack half-updated. The weekly fleet report catches that afterwards.
A merge is not a deploy
The same week, the GPU workstation turned out to have the same hole. Twenty-five scheduled jobs and my approval console ran from a Git checkout that nothing pulled. Merging a PR changed nothing on that machine until I happened to run git pull. On the collector host, the sync timer reported success every 15 minutes while pulling a different clone entirely.
That became ADR 0027, "A merge is not a deploy until a host pulls it." Any checkout that services run from is kept in step by a timer, and the timer itself is asserted. The sync fast-forwards or refuses. It never resets, stashes or switches branches, and it restarts a service only when HEAD moved.
The same bug, three more times
On 2026-09-09 the core host paged that its sync was blocked. It was still running the August 25 version of the script. A guard fix I had merged on the 27th had reached two of the four hosts it was meant for, because the script has no installer and gets copied to each host by hand. Fixed in the repo and fixed on the fleet turned out to be unrelated facts.
Two weeks later the refusal rule from the ADR bit me. The workstation checkout is also the tree I work in, so a refusal for a feature branch or a dirty tree exits 0 and logs "skipped". While a branch was checked out, 34 timers ran that branch's code and the sync looked green. The fix was a second clone that only automation touches, which is the option the ADR had considered and rejected.
On 2026-10-31 it happened again. The MCP server that gives Claude Code its view of my homelab was still launched from my working checkout, 92 commits behind main. That checkout's sync had been refusing for eight days because of uncommitted changes, and the memory compile's own status line said so. A "reconnect the MCP server" step the day before had restarted old code, and a tool I had merged never loaded. The launcher now points at the automation clone, and the tool list went from 95 to 96. The decision log entry's title says it: a reconnect loads the checkout the server runs from, not main.
What I took from it
The incident record says it directly: the mechanism reported success. Every repeat looked just as healthy from the outside, down to a sync that exited 0 while timers ran a feature branch.
Each fix was the same move. Stop trusting a signal that happens to be nearby, and check the thing itself: what Git tracks, which file a project runs from, which checkout a process was started in, whether the tool is actually in the list.
Written by
Adrian Romo
Senior Backend Engineer: Python backends, AWS, enterprise integrations, realtime voice systems, and AI infrastructure.
Related
Keep reading
Four Hours of CPU Nobody Asked For
In October this site was suspended on Vercel's free tier and its Neon database ran out of compute. Traffic was not the cause. Pages regenerating on timers were, and removing the timers took daily CPU from minutes to seconds.
The Update Cron That Patched Nothing
A weekly LXC update job fired on schedule for about sixteen months and installed nothing: a 404 script URL, with the error sent to /dev/null. Auditing every update mechanism found zeroes that meant nothing.
The Tool Nobody Called
I gave my homelab's agents one tool for grounded answers. It served 1 of 69 lookups, and my voice assistant called it in 0 of 32 turns. The nudges meant to fix that had been going to a debug log.
Keep going
Where to next?
Browse more technical writing, see the engineering case studies, or reach out directly.