# Why my daily restic backups ran every other day and re-read 1.46 TiB every time

> Three production bugs fixed in MyGround v0.1.112 to v0.1.114 on November 20, 2026: random Docker hostnames breaking restic parent snapshots, a 2 AM scheduler clock trap, and a Tailscale 502 on older Pi-hole installs.

Published November 21, 2026 on MyGround Notes: https://blog.myground.online/restic-docker-parent-snapshot-and-every-other-day-backups/

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](https://myground.online). 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:

```sh
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:

```sh
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](https://blog.myground.online/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:

```rust
// 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:

1. Day 1 at 02:00 UTC: the job starts.
2. Day 1 at 03:20 UTC: the job finishes and writes `last_run_at = 03:20 UTC`.
3. Day 2 at 02:00 UTC: the scheduler checks `(02:00 - 03:20)` — 22 hours and 40 minutes. `num_hours()` returns `22`, which is less than `24`.
4. Day 2 at 02:59 UTC: the last tick of the quiet hour sees 23 hours and 39 minutes. `num_hours()` returns `23`, still less than `24`.
5. Day 2 at 03:00 UTC: `now.hour()` is no longer `2`, so the window closes and Day 2 gets skipped completely.
6. 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`:

```rust
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`):

- **`network` mode**: the app and `ts-sidecar` share a Docker bridge network (`ts-net-<id>`), and `ts-serve.json` proxies to the compose service name (`http://pihole:80`).
- **`sidecar` mode**: the app shares the sidecar's network namespace via `network_mode: service:ts-sidecar`, and `ts-serve.json` proxies to `http://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`:

```rust
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:

1. **Always pass `--host <stable-name>` to containerized `restic backup`**, and add `--group-by host,paths,tags` if your container mounts different host paths onto the same mount point like `/data`. Check a second run's `--json` summary to confirm `files_unmodified` matches your file count instead of `files_new`.
2. **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](https://myground.online) from `v0.1.114` onward, and the full source and tests are in [backmeupplz/myground](https://github.com/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.

