fix(ops): backup failed on the MariaDB client shipped in the API image
Build and Push Images / Build jorgecuadros-api (push) Successful in 2m7s
Build and Push Images / Build jorgecuadros-web (push) Successful in 2m7s

Every backup on galactus died with:

  mysqldump: unknown variable 'set-gtid-purged=OFF'
  respaldo incompleto eliminado

Alpine's mysql-client is MariaDB's, so `mysqldump` inside the API
container is a shim over `mariadb-dump`, which has no --set-gtid-purged.
That took out BACKUP and, because they take a safety dump first, SYNC
and REIMPORT too.

Probe `mysqldump --help` and pass the flag only when it is advertised,
calling `mariadb-dump` directly otherwise — MariaDB writes no GTID state
unless asked with --gtid, so there is nothing to suppress. Testing
whether mariadb-dump merely exists would be wrong: on a host carrying
both clients it would shadow a perfectly good MySQL mysqldump.

The probe uses a command substitution rather than `--help | grep -q`
because PIPEFAIL is in effect for these commands and grep closing the
pipe early would report a supported flag as unsupported.

pre-migrate-backup.mjs is unaffected — it dumps from a real mysql:8.4
image, not from the API container.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-01 01:43:25 -07:00
co-authored by Claude Opus 5
parent 783ec83464
commit 860d483bad
2 changed files with 39 additions and 9 deletions
+13 -4
View File
@@ -294,10 +294,19 @@ a warning, which is what local development wants.
Two more things the panel's dumps now do, for the same reasons the pre-migrate
backup does them (see `deploy/scripts/pre-migrate-backup.mjs`):
- **`--set-gtid-purged=OFF`.** galactus is the replication *source* with GTID
on, so without this every dump embeds `SET @@GLOBAL.GTID_PURGED` and cannot be
restored onto the server it came from — which is precisely what the restore
screen exists to do.
- **`--set-gtid-purged=OFF`, but only when the dumper supports it.** galactus is
the replication *source* with GTID on, so on a MySQL client this flag is what
keeps every dump from embedding `SET @@GLOBAL.GTID_PURGED` and becoming
unrestorable onto the server it came from — which is precisely what the
restore screen exists to do. The panel, however, dumps from *inside the API
container*, where Alpine's `mysql-client` is MariaDB's: there `mysqldump` is a
shim over `mariadb-dump`, the flag does not exist, and passing it failed every
backup with `mysqldump: unknown variable 'set-gtid-purged=OFF'`. So the panel
probes `mysqldump --help` and passes the flag only if it is advertised,
invoking `mariadb-dump` directly otherwise (MariaDB writes no GTID state
unless asked with `--gtid`, so there is nothing to suppress). The pre-migrate
backup keeps the flag unconditionally — it runs in a real `mysql:8.4` image,
not in the API container.
- **`set -o pipefail` and a `CREATE TABLE` count.** `mysqldump | gzip` reports
gzip's exit status, and a `mysqldump` that dies on its first statement still
produces a ~372-byte perfectly valid archive that passes `gzip -t`. Without