Fix backend patch: use middlewared's actual site-packages dir, add direct file patching
site.getsitepackages()[0] returns /usr/local/lib/python3.11/dist-packages/ on TrueNAS 25.x but middlewared lives in /usr/lib/python3/dist-packages/. sitecustomize.py was installed to the wrong directory and Python never loaded it. Fix: derive SITE_PKG from middlewared.__file__ so the overlay and sitecustomize.py land in the correct directory. Also add direct patching of b2.py and restic.py in the overlay as the primary backend approach — more reliable than an import hook since it works regardless of Python's site initialisation configuration. apply.sh now also writes hook_status.json at boot time so 'verify' shows OK without requiring a backup run. Also fixes incorrect middlewared log path in README (/var/log/middlewared/middlewared.log → /var/log/middlewared.log) and simplifies the verify troubleshooting note.
This commit is contained in:
@@ -368,7 +368,7 @@ If one or more entries show `[FAIL]`:
|
||||
2. **Check middlewared's own log** for Python tracebacks:
|
||||
```bash
|
||||
# TrueNAS 25.x (logs to file):
|
||||
grep -i "truecloud\|traceback\|error" /var/log/middlewared/middlewared.log 2>/dev/null | tail -30
|
||||
grep -i "truecloud\|traceback\|error" /var/log/middlewared.log 2>/dev/null | tail -30
|
||||
# Older TrueNAS (logs to journal):
|
||||
journalctl -u middlewared -n 50
|
||||
```
|
||||
@@ -392,20 +392,14 @@ cat /mnt/tank/truenas-truecloud-patch/apply.log
|
||||
```bash
|
||||
python3 /mnt/tank/truenas-truecloud-patch/patch/create_task.py verify
|
||||
```
|
||||
This reads `hook_status.json` in your repo root. The file is written by the
|
||||
import hook the first time middlewared imports each patched module. These
|
||||
modules are loaded lazily — they are not imported at service start, only when
|
||||
a TrueCloud Backup operation runs (task creation, credential listing, backup
|
||||
execution). If `verify` reports "No hook status file found" immediately after
|
||||
install, that is normal: navigate to **Data Protection → TrueCloud Backup** in
|
||||
the UI or run a backup task to trigger the import, then run `verify` again.
|
||||
Does not require `--host` or `--api-key`.
|
||||
This reads `hook_status.json` in your repo root. The file is written by
|
||||
`apply.sh` at install/boot time and reflects whether the direct file patches
|
||||
to `b2.py` and `restic.py` were applied successfully. Does not require
|
||||
`--host` or `--api-key`.
|
||||
|
||||
**Middlewared log** (TrueNAS 25.x — middlewared logs to a file, not the journal):
|
||||
```bash
|
||||
find /var/log/middlewared -name "*.log" 2>/dev/null | head -3
|
||||
# then:
|
||||
grep truecloud-patch /var/log/middlewared/middlewared.log 2>/dev/null | tail -20
|
||||
grep truecloud-patch /var/log/middlewared.log 2>/dev/null | tail -20
|
||||
```
|
||||
On older TrueNAS versions that log to the journal:
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user