If you run restic backup inside ephemeral docker run --rm containers, restic will silently re-read and re-hash every file on disk on every single run unless you pass a fixed --host. And if you mount different volumes at the same container path like /data, --host alone is still not enough: you also need --group-by host,paths,tags so restic matches each volume to its own parent snapshot.
I learned that the slow way on my own photos server running MyGround. On November 20, 2026, we shipped three releases back to back (v0.1.112, v0.1.113 and v0.1.114) after noticing that Immich's 1.46 TiB backup was spending roughly an hour and a half per job, three jobs a night, and that the daily schedule was only firing on even-numbered days: November 2, 4, 6, all the way through November 20. Two of those bugs caused each other, and the third showed up the same afternoon when updating an older Pi-hole install over Tailscale.
Bug 1: ephemeral Docker containers break restic parent snapshots (v0.1.112)
MyGround does not require restic to be installed on the host. Every backup job spawns a fresh container from restic/restic:latest with docker run --rm (src/backup.rs), mounts the host volume read-only at /data:ro, and passes secrets through a temporary 0600 --env-file so passwords never show up in /proc.
Before v0.1.112 (PR #49), the backup arguments in backup_path_streaming looked like this:
restic backup /data --tag <tag> --json
Deduplication still worked, so S3 and local repositories did not store duplicate copies of unchanged photos. The problem was scanning. To skip re-reading unchanged files, restic looks for a parent snapshot in the repository and compares each file's path, size and modification time against that parent. By default, restic groups snapshots by (host, paths).
A fresh docker run --rm container gets a random 12-character hex container ID as its hostname every time it starts. On every backup run, restic looked for a previous snapshot with that brand-new hostname, found none, and fell back to reading and hashing every file from scratch. On a 1.46 TiB Immich library, that meant ~1.5 hours of full-disk I/O per job, three times a night.
The first instinct is to add --host myground and call it done. Testing that on the real photos server with restic 0.19.1 caught a second trap immediately: because MyGround mounts every app volume at /data inside the container, different volumes and database dumps in the same repository share both host=myground and paths=["/data"]. With --host myground alone, restic picked the newest snapshot from a different tag as the parent and still reported files_new=1.
The actual fix in src/backup.rs sets both the hostname and the grouping key:
restic backup /data \
--tag <tag> \
--host myground \
--group-by host,paths,tags \
--json
Re-running the same test on restic 0.19.1 with --group-by host,paths,tags picked the right parent snapshot and reported files_unmodified=1.
One detail to expect after upgrading to v0.1.112: the first backup per repository still reads every file once, because no existing snapshot has --host myground yet. Every run after that has a matching parent snapshot and skips unchanged files. (If you are curious how MyGround handles the database side before restic touches disk, I wrote up the six database dump hooks in How MyGround backs up app databases.)
Bug 2: a daily backup that only runs every other day (v0.1.113)
Slow full-disk scans were annoying on their own, but they also broke the scheduler.
MyGround's scheduler (src/scheduler.rs) wakes up every 60 seconds and calls should_run_now(schedule, job.last_run_at, Utc::now()). For the built-in presets (daily, weekly, monthly), match_preset only fires during the 02:00–02:59 UTC quiet hour and checks how long it has been since the previous run:
// Before v0.1.113
fn match_preset(
last: Option<&chrono::DateTime<Utc>>,
interval_hours: i64,
now: chrono::DateTime<Utc>,
) -> bool {
if now.hour() != 2 {
return false;
}
match last {
Some(last) => (now - *last).num_hours() >= interval_hours,
None => true,
}
}
At a glance, >= 24 hours for daily looks completely reasonable. The catch is in persist_job_status_with_label (src/backup.rs): job.last_run_at is recorded when the job finishes, not when it starts.
Trace what happened to the 1.46 TiB Immich backup:
- Day 1 at 02:00 UTC: the job starts.
- Day 1 at 03:20 UTC: the job finishes and writes
last_run_at = 03:20 UTC. - Day 2 at 02:00 UTC: the scheduler checks
(02:00 - 03:20)— 22 hours and 40 minutes.num_hours()returns22, which is less than24. - Day 2 at 02:59 UTC: the last tick of the quiet hour sees 23 hours and 39 minutes.
num_hours()returns23, still less than24. - Day 2 at 03:00 UTC:
now.hour()is no longer2, so the window closes and Day 2 gets skipped completely. - Day 3 at 02:00 UTC: 46 hours have passed, so it finally runs again.
Look in the server journal and you see backups on November 2, 4, 6, 8, and right on through November 20. Weekly backups had the exact same drift, running every 8 days instead of 7 whenever a job finished after 03:00 UTC.
The fix in v0.1.113 (PR #50) is one line in match_preset: subtract 12 hours of slack from interval_hours:
Some(last) => (now - *last).num_hours() >= interval_hours - 12,
That gives any daily job up to 12 hours to finish and still catch the next night's 2 AM window, while still blocking a second trigger inside the same 02:00–02:59 window (even a fast job that completes at 02:00:05 UTC is only 59 minutes old at 02:59, far below 12 hours, and should_run_now also has a 30-minute guard at the top). The regression test preset_runs_every_window_after_a_long_run now pins both the daily (22h 40m elapsed) and weekly (6 days, 22h 40m elapsed) cases, plus the same-window non-repeat check at 02:59.
Bug 3: Tailscale 502s when a catalog app changes tailscale_mode (v0.1.114)
The third bug hit the same afternoon on Pi-hole.
MyGround supports two ways of attaching a Tailscale sidecar to an app (src/apps.rs):
-
networkmode: the app andts-sidecarshare a Docker bridge network (ts-net-<id>), andts-serve.jsonproxies to the compose service name (http://pihole:80). -
sidecarmode: the app shares the sidecar's network namespace vianetwork_mode: service:ts-sidecar, andts-serve.jsonproxies tohttp://127.0.0.1:80.
Back on May 3, 2026 (commit 0c94312), Pi-hole's catalog definition (apps/pihole.toml) switched from network to sidecar so Tailscale DNS works cleanly on port 53. Fresh Pi-hole installs got the new docker-compose.yml with network_mode: service:ts-sidecar. Existing installs kept their original docker-compose.yml on disk, still wired over ts-net-pihole.
On startup, regenerate_all_serve_configs (src/tailscale.rs) checks every installed app and rewrites ts-serve.json if the generated config differs from what is on disk. Because it passed the catalog definition's tailscale_mode directly into tailscale_proxy_target, it saw "sidecar" in apps/pihole.toml, wrote http://127.0.0.1:80 into ts-serve.json, and restarted the proxy. Inside the older install's sidecar container, nothing was listening on 127.0.0.1:80, so every request to the Pi-hole admin panel came back HTTP 502.
In v0.1.114 (PR #51), regenerate_all_serve_configs inspects the deployed docker-compose.yml first through deployed_tailscale_mode:
fn deployed_tailscale_mode<'a>(eff_mode: &'a str, compose_yaml: &str) -> &'a str {
if eff_mode == "sidecar"
&& main_service_network_mode(compose_yaml).as_deref() != Some("service:ts-sidecar")
{
"network"
} else {
eff_mode
}
}
If the catalog says "sidecar" but the deployed compose file does not actually set network_mode: service:ts-sidecar, MyGround falls back to "network" and keeps proxying to http://pihole:80 until the app's compose file is regenerated.
What to copy if you run your own backup containers
Even if you never touch MyGround, two of these lessons apply to any self-hosted Docker backup script:
-
Always pass
--host <stable-name>to containerizedrestic backup, and add--group-by host,paths,tagsif your container mounts different host paths onto the same mount point like/data. Check a second run's--jsonsummary to confirmfiles_unmodifiedmatches your file count instead offiles_new. -
Never gate a fixed-window daily scheduler on
now - last_finished >= 24h. Either store the run's start timestamp, compare calendar dates, or allow slack so a slow backup that finishes after the window closes does not quietly turn your daily backup into an every-other-day backup.
All three fixes are live in MyGround from v0.1.114 onward, and the full source and tests are in backmeupplz/myground (MIT). The code paths and tests above were read directly from v0.1.114 on November 21, 2026; the restic 0.19.1 parent-snapshot check and Immich backup timings come from the November 20 server run logged on PRs #49 and #50.
Top comments (9)
Two bugs causing each other is the part I will remember, and the
num_hours()truncation is nastier than it looks because the journal is completely innocent — you get dates, not gaps. I hit the same shape somewhere much duller: a nightly SQL dump scheduled by a small job runner that gated on a duration sincelast_run_at, andlast_run_atwas written when the job finished. The dumps took 70 to 90 minutes, so "at least 24 hours since the last run" quietly became every second night, and it took a colleague noticing a missing Sunday file to find it. I ended up comparing calendar dates inside the window and storing the start time separately, because the slack you added works right up until retention grows or the dataset does and the job creeps past the edge of the window again.On the restic side,
--group-by host,paths,tagsis the detail I would have missed entirely. My containers mount one volume each, so--hostwas enough and I never had to think about the parent snapshot — and I would have readfiles_new=1as a success without ever looking atfiles_unmodified. One thing I would add to your checklist: count snapshots per tag over the last seven days and alert when the gap between two of them goes past 30 hours. The job status tells you a run happened; the repository is the only place that knows whether the schedule you think you have is the schedule you actually have.Thanks, and your SQL dump story is the same bug down to the detail. You're right that the slack has a ceiling: a job that grows past 12 hours drifts again, while comparing calendar dates and storing the start time don't care how long the run takes.
The per-tag gap check is a good one. The job status only knows a run happened, and the snapshots are the only record of what actually landed in the repository, so a 30-hour gap alert would have caught the every-other-day schedule on its second night instead of weeks later.
Exactly — the 12-hour slack only buys time until a run gets long enough to drift again. Comparing calendar dates and recording the start time is the part that actually holds, because it doesn't care how long the dump takes. And you're right about the snapshots: the job status told me a run happened, the repository is the only place that showed nothing new had landed. That per-tag gap check would have caught mine on the second night instead of weeks later.
The random container hostname breaking parent snapshot lookup is such a sneaky one. Dedup still works, so nothing looks broken, it's just quietly re-hashing 1.46 TiB every night. Did you add any check that would have flagged it earlier, like comparing job duration against the previous run?
Honestly, no automatic check yet. It got caught by eye: the Immich job took about an hour and a half every run, far too long for an incremental backup, and then the journal only had even dates in it. Comparing the duration to the previous run would have flagged it, and so would checking
files_newagainstfiles_unmodifiedin restic's JSON summary after each run, since a missed parent snapshot shows up there right away.Thanks, both of these are better than what I had in the post.
Changing the default in daemon.json flips the whole problem around: publishing to the world becomes the explicit choice instead of the accident. The "containers have to be recreated" part is worth repeating, because a restart alone won't pick it up.
The DOCKER-USER point is exactly the kind of trap I was hoping someone would bring up. Matching --dport after DNAT and wondering why the rule never fires is easy to do. Thanks for the conntrack version and the reminder about ip6tables and persisting the rules.
And agreed on the outside scan. A local audit tells you what Docker thinks it published, nmap from another machine tells you what's actually reachable. I'd run both.
a slow backup pushes last_run_at past the 02:00 window and the journal still shows clean even dates. recording the start time instead of the finish time is the fix that catches both.
Agreed, the start time is the cleaner fix. In v0.1.113 I went with 12 hours of slack, which still keeps a fast job from running twice in the same window, but slack only holds until the job grows past it. Storing when the run started, or just comparing calendar dates, doesn't have that ceiling.
Twelve hours of slack holds until the job outgrows it. Start time has no ceiling to hit.