M19: deriveStackName cross-references deployed stacks (fix DB-container misattribution)

deriveStackName pure-suffix-stripped on '-' (postgres/db/mariadb/.../cache), so a
stack whose slug ENDS in a role token (e.g. 'my-cache') was misattributed (stripped
to 'my') — filing its DB dump under the wrong/nonexistent stack. Now threads the set
of deployed stack names (m.knownStackNames() <- ListDeployedStacks) into
DiscoverDatabases and cross-references: candidate suffix-strip if known, else the
container name if it IS a known stack, else longest known stack that is a prefix
(handles <stack>_postgres / <stack>-1), else legacy strip. nil/empty known = legacy
behaviour (appexport passes nil). Table test incl. the my-cache case (fails pre-fix).
This commit is contained in:
2026-06-14 14:08:56 +02:00
parent 2d3bf64eeb
commit 6bab68b132
6 changed files with 142 additions and 11 deletions
+1 -1
View File
@@ -510,7 +510,7 @@ func (e *Exporter) dumpDatabase(stackName, dbDir string, manifest *Manifest) boo
defer cancel()
e.debugf("discovering databases (looking for stack %s)...", stackName)
dbs, err := appbackup.DiscoverDatabases(ctx, e.logger, e.debug)
dbs, err := appbackup.DiscoverDatabases(ctx, e.logger, e.debug, nil)
if err != nil {
e.logger.Printf("[WARN] Export: DB discovery error: %v", err)
return false