Scripts for the machine-layout move #7

Merged
thodkatz merged 4 commits from change/move-scripts into main 2026-11-05 10:46:57 +00:00
Owner

Change. The machine-layout move (docs/guides/moving-to-the-machine-layout.md) as one script per machine, at the user's request ("are there scripts for that to just run them on the vps?"), with the constraint "make sure that we don't delete data, only trying to move".

What changes

  • docs/guides/move-vps.sh: the guide's The VPS steps 1–6. Run as root; git runs as the clone's owner.
  • docs/guides/move-nixos.sh: the guide's The NixOS host steps 1–6. Run as the user; the move runs inside podman unshare.
  • The guide gets a The scripts section (how to fetch each one from origin/main before the pull). Its intro, its Done section, BACKLOG.md Next and docs/README.md now name the scripts, so the agent that deletes the guide deletes them too.

Safety, the user's constraint. Neither script deletes a file or a volume: compose down without -v, mv and rmdir (empty directories only), plus cp -a for the old ente. It does not delete the clone's old ente/ or a half-done copy of it; it tells the user to. Each script asks before stopping anything. It stops on every check the guide has you stop on: changed tracked files, ente's volume not ente_postgres-data, a container still running from an old directory, a not moved, … exists clash. It also stops with STOPPED: line N on any failing command. It skips what is done, so a re-run resumes. A volume snapshot taken before the run is compared after the start, to catch a stack that started empty.

Check. Each script was run against a scratch clone reset to 3f0e6da (the old layout, origin/main ahead), with untracked state in it and stub docker/podman/id/sudo/curl: --dry-run changes nothing; the full run leaves every piece of state under vps/ / nixos/, git status --ignored shows nothing left in the old directories, ente is copied with the acbff43 compose file and the original is kept; a re-run says already … and starts again; a clash stops before the start and overwrites nothing; a failing start prints STOPPED. shellcheck -e SC2015 is clean (SC2015 is the guide's own move_state && rmdir || …).

Rules this PR removes or rewrites: the guide's step 3 on both machines, git pull, is now git merge --ff-only @{u} (offline, to what step 1 fetched), because the origin is forgejo on the VPS, which step 2 stops; it lives in the same step. The repo-layout spec's D10 check gains ':!docs/guides/move-*.sh' (clarification 3, folded). Nothing else is removed.

🤖 Generated with Claude Code

**Change.** The machine-layout move (`docs/guides/moving-to-the-machine-layout.md`) as one script per machine, at the user's request ("are there scripts for that to just run them on the vps?"), with the constraint "make sure that we don't delete data, only trying to move". **What changes** - `docs/guides/move-vps.sh`: the guide's *The VPS* steps 1–6. Run as root; git runs as the clone's owner. - `docs/guides/move-nixos.sh`: the guide's *The NixOS host* steps 1–6. Run as the user; the move runs inside `podman unshare`. - The guide gets a *The scripts* section (how to fetch each one from `origin/main` before the pull). Its intro, its *Done* section, `BACKLOG.md` *Next* and `docs/README.md` now name the scripts, so the agent that deletes the guide deletes them too. **Safety, the user's constraint.** Neither script deletes a file or a volume: `compose down` without `-v`, `mv` and `rmdir` (empty directories only), plus `cp -a` for the old ente. It does not delete the clone's old `ente/` or a half-done copy of it; it tells the user to. Each script asks before stopping anything. It stops on every check the guide has you stop on: changed tracked files, ente's volume not `ente_postgres-data`, a container still running from an old directory, a `not moved, … exists` clash. It also stops with `STOPPED: line N` on any failing command. It skips what is done, so a re-run resumes. A volume snapshot taken before the run is compared after the start, to catch a stack that started empty. **Check.** Each script was run against a scratch clone reset to `3f0e6da` (the old layout, `origin/main` ahead), with untracked state in it and stub `docker`/`podman`/`id`/`sudo`/`curl`: `--dry-run` changes nothing; the full run leaves every piece of state under `vps/` / `nixos/`, `git status --ignored` shows nothing left in the old directories, ente is copied with the `acbff43` compose file and the original is kept; a re-run says `already …` and starts again; a clash stops before the start and overwrites nothing; a failing start prints `STOPPED`. `shellcheck -e SC2015` is clean (SC2015 is the guide's own `move_state && rmdir || …`). **Rules this PR removes or rewrites:** the guide's step 3 on both machines, `git pull`, is now `git merge --ff-only @{u}` (offline, to what step 1 fetched), because the origin is forgejo on the VPS, which step 2 stops; it lives in the same step. The repo-layout spec's D10 check gains `':!docs/guides/move-*.sh'` (clarification 3, folded). Nothing else is removed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: theo <thodkatz@pm.me>
thodkatz changed title from WIP: Scripts for the machine-layout move to Scripts for the machine-layout move 2026-11-05 10:40:39 +00:00
The move guide is a dozen copy-paste blocks per machine, with checks to read
between them. The user asked for something to just run, and for a guarantee that it
only moves data, never deletes it. So each machine gets a script that runs the
guide's steps, asks before it stops anything, stops with STOPPED on every check the
guide has you stop on, and skips what is done, so a re-run after a fix resumes. It
never removes a file or volume: down without -v, rmdir only on empty directories,
and the old ente/ (and any half-done copy of it) is left for the user to delete.
Both were run end to end against a scratch clone at 3f0e6da with stub
docker/podman: dry run, full run, re-run, and a name clash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
They name the old directories by design, like the guide they automate, and go
with it; without the exclusion D10 fails on a correct tree (PR #7 review).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
Author
Owner

Local review round (correctness/data-safety + methodology reviewers):

  1. Critical: the pull ran after forgejo (the clone's origin, on the VPS) was stopped, so it failed with everything down. The guide had the same flaw. Fixed in ae88cd9: step 3 is git merge --ff-only @{u} to step 1's fetch, in both scripts and the guide.
  2. Important: a clone that can't fast-forward was only found after the stop. Fixed: step 1 checks merge-base --is-ancestor HEAD @{u} and that @{u} has the new layout.
  3. Minor: "already pulled" was a directory test. Fixed: merge-base --is-ancestor 5eaafbb HEAD.
  4. Minor: the systemd backup-job check printed nothing. Fixed: grep -H over .service and .timer.
  5. Minor: ente copied without its volume present. Fixed: it refuses without ente_postgres-data.
  6. Minor: sudo -u kept root's HOME. Fixed: sudo -H -u.
  7. Minor: a symlinked clone path. Fixed: the old-dirs check also matches the realpath.
  8. Minor: the host's pull depended on the VPS's forgejo. Fixed by 1.
  9. Minor (methodology): spec D10's check flagged the scripts. Fixed in c26b048: the pathspec excludes them, with clarification 3 (folded).

No data-loss path was found: no rm, no compose -v, mv only onto absent names, and no ignored-file collision in the pull. Re-tested on scratch clones with the origin going offline mid-run: both machines complete; a non-fast-forward clone stops before any compose down.

Sign-off branch check: clean. sync-agents.py --check: exit 0.
Checks: AGENTS.md Setup check command: exit 0

Local review round (correctness/data-safety + methodology reviewers): 1. Critical: the pull ran after forgejo (the clone's origin, on the VPS) was stopped, so it failed with everything down. The guide had the same flaw. Fixed in `ae88cd9`: step 3 is `git merge --ff-only @{u}` to step 1's fetch, in both scripts and the guide. 2. Important: a clone that can't fast-forward was only found after the stop. Fixed: step 1 checks `merge-base --is-ancestor HEAD @{u}` and that `@{u}` has the new layout. 3. Minor: "already pulled" was a directory test. Fixed: `merge-base --is-ancestor 5eaafbb HEAD`. 4. Minor: the systemd backup-job check printed nothing. Fixed: `grep -H` over `.service` and `.timer`. 5. Minor: ente copied without its volume present. Fixed: it refuses without `ente_postgres-data`. 6. Minor: `sudo -u` kept root's HOME. Fixed: `sudo -H -u`. 7. Minor: a symlinked clone path. Fixed: the old-dirs check also matches the realpath. 8. Minor: the host's pull depended on the VPS's forgejo. Fixed by 1. 9. Minor (methodology): spec D10's check flagged the scripts. Fixed in `c26b048`: the pathspec excludes them, with clarification 3 (folded). No data-loss path was found: no rm, no compose -v, mv only onto absent names, and no ignored-file collision in the pull. Re-tested on scratch clones with the origin going offline mid-run: both machines complete; a non-fast-forward clone stops before any compose down. Sign-off branch check: clean. sync-agents.py --check: exit 0. Checks: AGENTS.md Setup check command: exit 0
The VPS clone's origin is forgejo on the VPS itself, so a `git pull` after step 2
stopped forgejo failed and left every service down (the guide had the same flaw,
on the host too since its origin is the same forgejo). Step 1 already fetches while
everything runs; step 3 now fast-forwards to that offline (`git merge --ff-only
@{u}`). Step 1 also checks, before anything stops, that the clone can fast-forward
and that the fetched upstream has the new layout; "already pulled" is now "HEAD
contains 5eaafbb", not a directory test; the old ente copy refuses to run without
the ente_postgres-data volume; the backup-job check prints the systemd lines it
finds; sudo -H for the owner's git; the running-from-old-dirs check also matches
the clone's realpath. From the PR #7 correctness review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: theo <thodkatz@pm.me>
thodkatz deleted branch change/move-scripts 2026-11-05 10:46:57 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
thodkatz/selfhosted!7
No description provided.