Each server runs an ultralight probe (scratch image, ~7 MiB RSS) that tails the logs, ships raw lines to the hub over HTTPS with an on-disk spool, and applies enforce decisions locally. The hub keeps one node per probe (primary node = the 1.x data dir, unchanged), does all analysis and serves the UI. Peer federation is removed. 'urutau import' brings 1.x data dirs in with hash and count verification. UI: probes page, host qualified incidents, IPs never wrap, egress heatmap labels, live and replay globes no longer auto-rotate, replay repeat, live traffic metrics. BREAKING CHANGE: URUTAU_PEERS, URUTAU_PEER_* and /api/v1/peer/* are gone; log path variables move from the hub to the probe. See docs/migration-2.0.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
173 lines
8.5 KiB
Markdown
173 lines
8.5 KiB
Markdown
# Migrating from 1.x to 2.0
|
|
|
|
Urutau 2.0 replaces peer federation with probes. The hub keeps one node per probe, and each node has its own
|
|
data directory in the same format as 1.x. Your registered data is not converted, merged or rewritten: it is
|
|
copied byte for byte and then verified. Nothing in this procedure deletes data.
|
|
|
|
| What | Before (1.6) | After (2.0) |
|
|
| --- | --- | --- |
|
|
| Primary host (Oracle) | data dir `/data` | the same files, as the hub's own data dir, with no conversion |
|
|
| Second host (Hostinger) | its own 1.6 instance, polled as a peer | `urutau import` copies its data dir to `/data/probes/hostinger/` |
|
|
| Incident IDs | `INC-3` | `hostinger/INC-3` (the primary host keeps `INC-3`; the old IDs stay valid inside their host) |
|
|
|
|
Removed variables make the hub refuse to start (`URUTAU_PEERS`, `URUTAU_PEER_TOKEN*`, `URUTAU_PEER_ALLOW`,
|
|
`URUTAU_PEER_BLOCKLIST` and the log path variables). See `CHANGELOG.md`.
|
|
|
|
## What the 1.6 data directory contains
|
|
|
|
Everything below is copied. Unknown files are copied too.
|
|
|
|
| Path | Content |
|
|
| --- | --- |
|
|
| `urutau-state.gob` | snapshot: counters, IP registry, feed, **read offsets of each log** |
|
|
| `urutau-state.gob.tmp`, `urutau-state.gob.corrupt` | leftovers of a crash (copied if present) |
|
|
| `events/*.jsonl`, `events/*.jsonl.gz`, `events/*.idx` | event registry, one file per day |
|
|
| `incidents.json` (+ `incidents.json.corrupt-<ts>`) | incidents with comments, history and suppression |
|
|
| `enforce.json` (+ `.tmp`) | ban history, offences and allows of the enforcement engine |
|
|
| `tor/` | Tor exit and relay list cache |
|
|
| `geo/` | geolocation databases, **skipped by default** (the hub downloads its own; add `--include-geo` to copy) |
|
|
| anything else | copied verbatim |
|
|
|
|
The ban decision files (`decisions.log`, `unban.log`) are not in the data dir: they live on the host
|
|
(`/var/log/urutau-enforce`) and stay there; the probe keeps writing them.
|
|
|
|
## Cutover
|
|
|
|
Every command below is run per host. Replace `<ts>` with a timestamp. Keep the 1.6 apps and their volumes
|
|
untouched until the end: they are the rollback.
|
|
|
|
### 0. Backup and counts (before changing anything)
|
|
|
|
On each host:
|
|
|
|
```sh
|
|
docker compose stop urutau # short stop, so the files are consistent
|
|
docker run --rm -v urutau-data:/data -v "$PWD":/out alpine \
|
|
tar --numeric-owner -czf /out/urutau-data-$(hostname)-<ts>.tgz -C /data .
|
|
sha256sum urutau-data-*-<ts>.tgz | tee urutau-data-<ts>.sha256
|
|
docker compose start urutau
|
|
```
|
|
|
|
Copy both tarballs and their `.sha256` to the Oracle and to a copy outside both servers (your machine), and
|
|
check the sums there. Keep the tarballs for 90 days.
|
|
|
|
Record the counts. The files give exact numbers (extract each tarball to a scratch directory):
|
|
|
|
```sh
|
|
mkdir -p /tmp/count-oracle && tar -xzf urutau-data-oracle-<ts>.tgz -C /tmp/count-oracle
|
|
urutau import --count /tmp/count-oracle # 2.0 binary
|
|
# events=... event_files=... ips=... offsets=... incidents=... comments=... suppressed=... enforce_bans=... enforce_allow=...
|
|
```
|
|
|
|
and write down what the running 1.6 API says, as a second opinion (summary for 30 days, incidents, active bans):
|
|
|
|
```sh
|
|
curl -s -H "Authorization: Bearer $URUTAU_TOKEN" 'https://<host>/api/v1/summary?range=30d'
|
|
curl -s -H "Authorization: Bearer $URUTAU_TOKEN" 'https://<host>/api/v1/incidents?per_page=1' # "total"
|
|
```
|
|
|
|
Do the same for the Hostinger tarball. Save all numbers in a note.
|
|
|
|
### 1. New hub on a new volume (Oracle)
|
|
|
|
Do not reuse the volume in use: that keeps the rollback trivial. Restore the Oracle tarball into a new volume:
|
|
|
|
```sh
|
|
docker volume create urutau2-data
|
|
docker run --rm -v urutau2-data:/data -v "$PWD":/in alpine \
|
|
tar --numeric-owner -xzf /in/urutau-data-oracle-<ts>.tgz -C /data
|
|
```
|
|
|
|
Start the 2.0 hub on that volume with `URUTAU_NAME` equal to the name the Oracle 1.6 used (the primary node uses
|
|
the volume root, exactly the 1.6 format), on an internal port, with no public domain yet. Check that the
|
|
primary node's counts equal step 0 (`docker exec <hub> urutau import --count /data`, and the Incidents and
|
|
Overview pages).
|
|
|
|
### 2. Create the probes
|
|
|
|
```sh
|
|
docker exec <hub> urutau probes create oracle # prints the token once
|
|
docker exec <hub> urutau probes create hostinger
|
|
```
|
|
|
|
Put each token in the `.env` of its host as `URUTAU_PROBE_TOKEN`. The hub stores only its SHA-256.
|
|
|
|
### 3. Oracle
|
|
|
|
Stop the 1.6 app, point the domain to the 2.0 hub and start the Oracle probe
|
|
(`URUTAU_HUB_URL=http://urutau:8790` on the internal network). Check on the Sources page: connected, lag under
|
|
5 seconds, no gap. The hello answer carries the read offsets saved in the snapshot, so the probe continues
|
|
exactly where 1.6 stopped. Keep `URUTAU_ENFORCE=observe` for 30 minutes, confirm `decisions.log` is
|
|
receiving lines, then switch to `on`.
|
|
|
|
### 4. Hostinger
|
|
|
|
1. Stop the 1.6 app there. Make a final tarball (it contains what arrived since step 0) and copy it to the
|
|
Oracle. Extract it into an empty directory, for example `/srv/import/hostinger`.
|
|
2. Stop the hub (the import refuses to run while `<data-dir>/.lock` exists):
|
|
|
|
```sh
|
|
docker compose stop urutau
|
|
```
|
|
|
|
3. Rehearse, then import, then verify. The data dir is the hub's volume (mounted at `/data`):
|
|
|
|
```sh
|
|
docker run --rm -v urutau2-data:/data -v /srv/import/hostinger:/from:ro <hub-image> \
|
|
urutau import --from /from --host hostinger --data-dir /data --dry-run
|
|
docker run --rm -v urutau2-data:/data -v /srv/import/hostinger:/from:ro <hub-image> \
|
|
urutau import --from /from --host hostinger --data-dir /data
|
|
docker run --rm -v urutau2-data:/data -v /srv/import/hostinger:/from:ro <hub-image> \
|
|
urutau import --verify --from /from --host hostinger --data-dir /data
|
|
```
|
|
|
|
The import prints the counts. They must equal the Hostinger numbers from step 0 (plus whatever the final
|
|
tarball added). Running the import again prints "already imported" and does nothing.
|
|
4. Start the hub. The `hostinger` node shows the same events, IPs and incidents (`hostinger/INC-2` with its
|
|
comments, suppressions intact) and ban history. Compare with the numbers you wrote down.
|
|
5. Start the Hostinger probe (`URUTAU_HUB_URL=https://<hub domain>`). The hello answer returns the imported
|
|
offsets, so there is no gap and no duplicate.
|
|
|
|
### 5. Observe, then clean up
|
|
|
|
Watch for one week. Then remove the old Hostinger Coolify app, its domain
|
|
(`urutau-hostinger.lucasrguerra.dev.br`), DNS record and certificate. Keep the tarballs 90 days and the old
|
|
Oracle volume until you are sure.
|
|
|
|
## `urutau import` reference
|
|
|
|
```
|
|
urutau import --from DIR --host NAME [--data-dir D] [--dry-run] [--force] [--include-geo]
|
|
urutau import --verify --from DIR --host NAME [--data-dir D]
|
|
urutau import --count DIR
|
|
```
|
|
|
|
- Copies **everything** in `DIR` to `<data-dir>/probes/NAME/`, into a temporary directory that is renamed into
|
|
place only after the copy was verified. Mode and mtime are preserved.
|
|
- The check compares the sha256 of every file, then loads the snapshot, the event registry, `incidents.json` and
|
|
`enforce.json` with the 1.x code and compares the counts with the source. It also confirms the source did
|
|
not change while it was copied. Any difference aborts before anything is installed.
|
|
- `import-manifest.json` inside the destination records every hash and the counts. A second run with the same
|
|
source prints "already imported" and does nothing.
|
|
- If the destination exists with other content, the command fails and changes nothing. `--force` moves it to
|
|
`NAME.bak-<timestamp>` next to it; nothing is ever deleted.
|
|
- `--dry-run` reads and compares, and writes nothing (not even directories).
|
|
- The import refuses to run while `<data-dir>/.lock` exists (the hub is running). While it runs, it holds that
|
|
file itself, so the hub cannot start in the middle. A stale file after a crash must be removed by hand.
|
|
- `--verify` compares the source with the imported copy (hashes, mode, mtime, counts). Use it before the hub
|
|
starts on the destination, because the hub rewrites the snapshot as it runs.
|
|
- `--count DIR` never writes to `DIR`.
|
|
- Exit status: 0 on success, 1 on any failure, 2 on bad usage.
|
|
|
|
## Rollback
|
|
|
|
At any step: stop the hub and the probes, start the 1.6 apps on their original volumes again, restore the DNS.
|
|
Those volumes were not touched. At steps 3 and 4 the 1.6 instances were stopped, so starting them resumes from
|
|
their own offsets. You lose only what 2.0 processed in between, and the raw logs are still on each host to be
|
|
processed again. If an import was wrong, nothing is lost either: the failed copy is never installed, and
|
|
`--force` keeps the old one as `.bak-<timestamp>`.
|
|
|
|
## Résumé en portugais
|
|
|
|
Veja [pt-BR/migracao-2.0.md](pt-BR/migracao-2.0.md).
|