Add migrate --plan: many accounts moved by one plan file #38

Merged
jcoffey-dev merged 1 commits from feat/migrate-plan into main 2026-10-30 16:26:04 +00:00
Owner

Adds migrate --plan, the domain runner from roadmap item 12. One plan file names:

  • the setup steps (import-directory or export-directory, run once);
  • the steps for each account;
  • the accounts, either listed or taken from the users in a directory.json.

Each step is an ordinary inbuxa-migrate command line. {email}, {local}, {domain} and {archive} are filled in for each account, so every source the tool already reads works without new code.

  • Runs: each step runs as its own process of the same binary, in the plan's directory, with stdin closed. --parallel (default 4) sets how many accounts run at once, and each account step writes its own log under <DIR>/<email>/.
  • Secrets: a step names the environment variable that holds each secret it needs. The other secret variables are cleared, so a step never sees a secret it didn't name. A plan that writes a password or token into args is refused, and so is a bare --auth-bearer that would swallow {archive}.
  • Resume: a second run skips the accounts that finished. For the rest, it starts from each account's first step that wasn't done. --again runs every step once more, for the final pass. A failed step stops its account, a partial one (exit 5) doesn't, and a failed setup step stops the run.
  • Report: report.csv has one row per step per account: the result, the counts and the last error. The work directory is mode 700 and the logs are 600.

Tests:

  • tests/mock_migrate.rs drives the real binary offline (Maildir in, export-files out):
    • one account fails while the other finishes;
    • the second run resumes only the one that failed;
    • --again --account picks up a new message;
    • a step's secret that isn't set is refused, and a secret the step didn't name is not passed on.
  • Unit tests cover the arg checks, the placeholders, the account addresses and the count parsing.
  • Live, against an inbuxa 27.1-rc.4 container: the setup step ran import-directory from the plan, both Maildir imports ran, and the export failures came back in the report with the server's reason.

Not verified yet: an export step into a fully set-up inbuxa, acting for each account. The test container never finished inbuxa's bootstrap, so it grants only bootstrap permissions, and inbuxa's JMAP takes tokens, not Basic, outside recovery mode. So the per-account target login (an admin token reaching each account by name) still needs a fully set-up inbuxa to check against. That fits roadmap item 14.

Adds `migrate --plan`, the domain runner from roadmap item 12. One plan file names: - the setup steps (`import-directory` or `export-directory`, run once); - the steps for each account; - the accounts, either listed or taken from the users in a `directory.json`. Each step is an ordinary inbuxa-migrate command line. `{email}`, `{local}`, `{domain}` and `{archive}` are filled in for each account, so every source the tool already reads works without new code. - **Runs:** each step runs as its own process of the same binary, in the plan's directory, with stdin closed. `--parallel` (default 4) sets how many accounts run at once, and each account step writes its own log under `<DIR>/<email>/`. - **Secrets:** a step names the environment variable that holds each secret it needs. The other secret variables are cleared, so a step never sees a secret it didn't name. A plan that writes a password or token into `args` is refused, and so is a bare `--auth-bearer` that would swallow `{archive}`. - **Resume:** a second run skips the accounts that finished. For the rest, it starts from each account's first step that wasn't done. `--again` runs every step once more, for the final pass. A failed step stops its account, a partial one (exit 5) doesn't, and a failed setup step stops the run. - **Report:** `report.csv` has one row per step per account: the result, the counts and the last error. The work directory is mode 700 and the logs are 600. Tests: - `tests/mock_migrate.rs` drives the real binary offline (Maildir in, export-files out): - one account fails while the other finishes; - the second run resumes only the one that failed; - `--again --account` picks up a new message; - a step's secret that isn't set is refused, and a secret the step didn't name is not passed on. - Unit tests cover the arg checks, the placeholders, the account addresses and the count parsing. - Live, against an inbuxa 27.1-rc.4 container: the setup step ran `import-directory` from the plan, both Maildir imports ran, and the export failures came back in the report with the server's reason. Not verified yet: an export step into a **fully set-up** inbuxa, acting for each account. The test container never finished inbuxa's bootstrap, so it grants only bootstrap permissions, and inbuxa's JMAP takes tokens, not Basic, outside recovery mode. So the per-account target login (an admin token reaching each account by name) still needs a fully set-up inbuxa to check against. That fits roadmap item 14.
jcoffey-dev added 1 commit 2026-10-30 16:20:51 +00:00
Add migrate --plan: many accounts moved by one plan file
ci / test (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 4m50s
ci / announce (pull_request) Skipped
a50733c924
A plan names setup steps (import-directory or export-directory, run once),
the steps for each account, and the accounts, listed or taken from the
users in a directory.json. A step is one inbuxa-migrate command line as
the docs write it, with {email}, {local}, {domain} and {archive} filled in
per account, so every source the tool reads works with no new code.

Each step runs as a child of the same binary in the plan's directory,
with stdin closed and only the secrets it names: secrets are given by
environment variable, all others are cleared, and a plan that writes a
password or token into its args is refused. Output goes to an append-only
log per account and step; --parallel accounts run at once.

The work directory (mode 700) holds an archive per account, state.json
and report.csv. A second run skips finished accounts and, for the rest,
runs from the first step that wasn't done; --again runs every step once
more for the final pass. A failed step stops its account, a partial one
doesn't, and a failed setup step stops the run.
jcoffey-dev merged commit 8c76b09540 into main 2026-10-30 16:26:04 +00:00
jcoffey-dev deleted branch feat/migrate-plan 2026-10-30 16:26:04 +00:00
Sign in to join this conversation.