Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

FIX (ci \ cd): Mark DB client binaries executable in git and verify them in healthcheck

Rostislav Duginafc834a9d8d1
diff --git a/assets/tools/arm/mariadb/mariadb-10.6/bin/mariadb b/assets/tools/arm/mariadb/mariadb-10.6/bin/mariadb
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mariadb/mariadb-10.6/bin/mariadb-dump b/assets/tools/arm/mariadb/mariadb-10.6/bin/mariadb-dump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mariadb/mariadb-12.1/bin/mariadb b/assets/tools/arm/mariadb/mariadb-12.1/bin/mariadb
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mariadb/mariadb-12.1/bin/mariadb-dump b/assets/tools/arm/mariadb/mariadb-12.1/bin/mariadb-dump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mongodb/bin/mongodump b/assets/tools/arm/mongodb/bin/mongodump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mongodb/bin/mongorestore b/assets/tools/arm/mongodb/bin/mongorestore
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mysql/mysql-8.0/bin/mysql b/assets/tools/arm/mysql/mysql-8.0/bin/mysql
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mysql/mysql-8.0/bin/mysqldump b/assets/tools/arm/mysql/mysql-8.0/bin/mysqldump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mysql/mysql-8.4/bin/mysql b/assets/tools/arm/mysql/mysql-8.4/bin/mysql
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mysql/mysql-8.4/bin/mysqldump b/assets/tools/arm/mysql/mysql-8.4/bin/mysqldump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mysql/mysql-9/bin/mysql b/assets/tools/arm/mysql/mysql-9/bin/mysql
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/mysql/mysql-9/bin/mysqldump b/assets/tools/arm/mysql/mysql-9/bin/mysqldump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-12/bin/pg_dump b/assets/tools/arm/postgresql/postgresql-12/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-12/bin/pg_restore b/assets/tools/arm/postgresql/postgresql-12/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-12/bin/psql b/assets/tools/arm/postgresql/postgresql-12/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-13/bin/pg_dump b/assets/tools/arm/postgresql/postgresql-13/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-13/bin/pg_restore b/assets/tools/arm/postgresql/postgresql-13/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-13/bin/psql b/assets/tools/arm/postgresql/postgresql-13/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-14/bin/pg_dump b/assets/tools/arm/postgresql/postgresql-14/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-14/bin/pg_restore b/assets/tools/arm/postgresql/postgresql-14/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-14/bin/psql b/assets/tools/arm/postgresql/postgresql-14/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-15/bin/pg_dump b/assets/tools/arm/postgresql/postgresql-15/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-15/bin/pg_restore b/assets/tools/arm/postgresql/postgresql-15/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-15/bin/psql b/assets/tools/arm/postgresql/postgresql-15/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-16/bin/pg_dump b/assets/tools/arm/postgresql/postgresql-16/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-16/bin/pg_restore b/assets/tools/arm/postgresql/postgresql-16/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-16/bin/psql b/assets/tools/arm/postgresql/postgresql-16/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-17/bin/pg_dump b/assets/tools/arm/postgresql/postgresql-17/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-17/bin/pg_restore b/assets/tools/arm/postgresql/postgresql-17/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-17/bin/psql b/assets/tools/arm/postgresql/postgresql-17/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-18/bin/pg_dump b/assets/tools/arm/postgresql/postgresql-18/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-18/bin/pg_restore b/assets/tools/arm/postgresql/postgresql-18/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/arm/postgresql/postgresql-18/bin/psql b/assets/tools/arm/postgresql/postgresql-18/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mariadb/mariadb-10.6/bin/mariadb b/assets/tools/x64/mariadb/mariadb-10.6/bin/mariadb
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mariadb/mariadb-10.6/bin/mariadb-dump b/assets/tools/x64/mariadb/mariadb-10.6/bin/mariadb-dump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mariadb/mariadb-12.1/bin/mariadb b/assets/tools/x64/mariadb/mariadb-12.1/bin/mariadb
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mariadb/mariadb-12.1/bin/mariadb-dump b/assets/tools/x64/mariadb/mariadb-12.1/bin/mariadb-dump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mongodb/bin/mongodump b/assets/tools/x64/mongodb/bin/mongodump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mongodb/bin/mongorestore b/assets/tools/x64/mongodb/bin/mongorestore
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mysql/mysql-5.7/bin/mysql b/assets/tools/x64/mysql/mysql-5.7/bin/mysql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mysql/mysql-5.7/bin/mysqldump b/assets/tools/x64/mysql/mysql-5.7/bin/mysqldump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mysql/mysql-8.0/bin/mysql b/assets/tools/x64/mysql/mysql-8.0/bin/mysql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mysql/mysql-8.0/bin/mysqldump b/assets/tools/x64/mysql/mysql-8.0/bin/mysqldump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mysql/mysql-8.4/bin/mysql b/assets/tools/x64/mysql/mysql-8.4/bin/mysql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mysql/mysql-8.4/bin/mysqldump b/assets/tools/x64/mysql/mysql-8.4/bin/mysqldump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mysql/mysql-9/bin/mysql b/assets/tools/x64/mysql/mysql-9/bin/mysql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/mysql/mysql-9/bin/mysqldump b/assets/tools/x64/mysql/mysql-9/bin/mysqldump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-12/bin/pg_dump b/assets/tools/x64/postgresql/postgresql-12/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-12/bin/pg_restore b/assets/tools/x64/postgresql/postgresql-12/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-12/bin/psql b/assets/tools/x64/postgresql/postgresql-12/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-13/bin/pg_dump b/assets/tools/x64/postgresql/postgresql-13/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-13/bin/pg_restore b/assets/tools/x64/postgresql/postgresql-13/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-13/bin/psql b/assets/tools/x64/postgresql/postgresql-13/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-14/bin/pg_dump b/assets/tools/x64/postgresql/postgresql-14/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-14/bin/pg_restore b/assets/tools/x64/postgresql/postgresql-14/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-14/bin/psql b/assets/tools/x64/postgresql/postgresql-14/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-15/bin/pg_dump b/assets/tools/x64/postgresql/postgresql-15/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-15/bin/pg_restore b/assets/tools/x64/postgresql/postgresql-15/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-15/bin/psql b/assets/tools/x64/postgresql/postgresql-15/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-16/bin/pg_dump b/assets/tools/x64/postgresql/postgresql-16/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-16/bin/pg_restore b/assets/tools/x64/postgresql/postgresql-16/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-16/bin/psql b/assets/tools/x64/postgresql/postgresql-16/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-17/bin/pg_dump b/assets/tools/x64/postgresql/postgresql-17/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-17/bin/pg_restore b/assets/tools/x64/postgresql/postgresql-17/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-17/bin/psql b/assets/tools/x64/postgresql/postgresql-17/bin/psql
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-18/bin/pg_dump b/assets/tools/x64/postgresql/postgresql-18/bin/pg_dump
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-18/bin/pg_restore b/assets/tools/x64/postgresql/postgresql-18/bin/pg_restore
old mode 100644
new mode 100755
diff --git a/assets/tools/x64/postgresql/postgresql-18/bin/psql b/assets/tools/x64/postgresql/postgresql-18/bin/psql
old mode 100644
new mode 100755
diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go
index eeb17167..30131979 100644
--- a/backend/internal/config/config.go
+++ b/backend/internal/config/config.go
@@ -223,7 +223,7 @@ func loadEnvVariables() {
}
log.Info("ENV_MODE loaded", "mode", env.EnvMode)
- tools.VerifyAllClientTools(log, env.ShowDbInstallationVerificationLogs)
+ tools.LogAndExitIfClientToolsBroken(log, env.ShowDbInstallationVerificationLogs)
if env.NodeNetworkThroughputMBs == 0 {
env.NodeNetworkThroughputMBs = 125 // 1 Gbit/s
diff --git a/backend/internal/features/system/healthcheck/service.go b/backend/internal/features/system/healthcheck/service.go
index fd41de58..fcbf6462 100644
--- a/backend/internal/features/system/healthcheck/service.go
+++ b/backend/internal/features/system/healthcheck/service.go
@@ -10,6 +10,7 @@ import (
"databasus-backend/internal/features/disk"
"databasus-backend/internal/storage"
cache_utils "databasus-backend/internal/util/cache"
+ "databasus-backend/internal/util/tools"
)
type HealthcheckService struct {
@@ -42,6 +43,10 @@ func (s *HealthcheckService) performHealthCheck() error {
return errors.New("more than 95% of the disk is used")
}
+ if err := tools.ClientToolsHealthError(); err != nil {
+ return err
+ }
+
db := storage.GetDb()
err = db.Raw("SELECT 1").Error
if err != nil {
diff --git a/backend/internal/util/tools/common.go b/backend/internal/util/tools/common.go
index 0630355f..850f6bd5 100644
--- a/backend/internal/util/tools/common.go
+++ b/backend/internal/util/tools/common.go
@@ -1,10 +1,13 @@
package tools
import (
+ "errors"
+ "fmt"
"log/slog"
"os"
"path/filepath"
"runtime"
+ "strings"
)
// withExeOnWindows appends ".exe" when running on Windows.
@@ -16,56 +19,115 @@ func withExeOnWindows(name string) string {
return name
}
-// verifyBinDir checks that binDir exists and contains every command in
-// requiredCommands. Logs at the requested verbosity. Exits the process if
-// isFatal is true and anything is missing; otherwise warns and continues.
-func verifyBinDir(
- logger *slog.Logger,
- dbName, versionLabel, binDir string,
- requiredCommands []string,
- isFatal, isShowLogs bool,
-) {
- log := logger.With("db", dbName, "version", versionLabel, "path", binDir)
-
- if isShowLogs {
- log.Info("verifying client tools installation")
- }
+// ToolCheckResult is one DB-version bundle's verification outcome. A bundle
+// is considered fatal when missing/broken should crash the app at startup
+// (Postgres) and non-fatal otherwise (MySQL, MariaDB, MongoDB).
+type ToolCheckResult struct {
+ Db string
+ Version string
+ BinDir string
+ Errors []error
+ IsFatal bool
+}
+// checkBinDir verifies binDir exists and that every command in
+// requiredCommands is present and (on non-Windows) has the executable bit set.
+// Returns the collected errors. If the directory does not exist, returns a
+// single not-found error so callers can treat it differently for fatal vs
+// non-fatal bundles.
+func checkBinDir(binDir string, requiredCommands []string) []error {
if _, err := os.Stat(binDir); os.IsNotExist(err) {
- if isFatal {
- log.Error("client tools bin directory not found")
- os.Exit(1)
- }
-
- log.Warn("client tools bin directory not found - support disabled")
- return
+ return []error{fmt.Errorf("client tools bin directory not found: %s", binDir)}
}
+ var errs []error
for _, cmd := range requiredCommands {
cmdPath := filepath.Join(binDir, withExeOnWindows(cmd))
- if _, err := os.Stat(cmdPath); os.IsNotExist(err) {
- if isFatal {
- log.Error("client command not found", "command", cmd, "command_path", cmdPath)
- os.Exit(1)
+
+ info, err := os.Stat(cmdPath)
+ if os.IsNotExist(err) {
+ errs = append(errs, fmt.Errorf("client command not found: %s", cmdPath))
+ continue
+ }
+ if err != nil {
+ errs = append(errs, fmt.Errorf("cannot stat %s: %w", cmdPath, err))
+ continue
+ }
+
+ // Windows uses extension-based execution, so the unix exec bit is
+ // meaningless there.
+ if runtime.GOOS != "windows" && info.Mode().Perm()&0o111 == 0 {
+ errs = append(errs, fmt.Errorf("client command not executable: %s", cmdPath))
+ }
+ }
+
+ return errs
+}
+
+// CheckAllClientTools verifies every expected client binary for the current
+// arch is present and executable. Pure: never logs, never exits. Used by
+// startup (config) and runtime (healthcheck).
+func CheckAllClientTools() []ToolCheckResult {
+ results := checkPostgresql()
+ results = append(results, checkMysql()...)
+ results = append(results, checkMariadb()...)
+ results = append(results, checkMongodb()...)
+
+ return results
+}
+
+// LogAndExitIfClientToolsBroken logs every check result and exits the process
+// if any fatal-tier (Postgres) bundle has errors. Non-fatal bundles only warn.
+// Used by config at application startup.
+func LogAndExitIfClientToolsBroken(logger *slog.Logger, isShowLogs bool) {
+ results := CheckAllClientTools()
+
+ hasFatalError := false
+ for _, r := range results {
+ log := logger.With("db", r.Db, "version", r.Version, "path", r.BinDir)
+
+ if len(r.Errors) == 0 {
+ if isShowLogs {
+ log.Info("client tools verified")
}
- log.Warn("client command not found - support disabled",
- "command", cmd, "command_path", cmdPath)
continue
}
- if isShowLogs {
- log.Info("client command found", "command", cmd)
+ for _, err := range r.Errors {
+ if r.IsFatal {
+ log.Error("client tools check failed", "error", err)
+ hasFatalError = true
+ } else {
+ log.Warn("client tools check failed - support disabled", "error", err)
+ }
}
}
+
+ if hasFatalError {
+ os.Exit(1)
+ }
}
-// VerifyAllClientTools runs the per-DB verifications. Postgres is fatal;
-// MySQL/MariaDB/MongoDB are non-fatal (warn and continue) so the app stays
-// up when only some clients are present.
-func VerifyAllClientTools(logger *slog.Logger, isShowLogs bool) {
- VerifyPostgresqlInstallation(logger, isShowLogs)
- VerifyMysqlInstallation(logger, isShowLogs)
- VerifyMariadbInstallation(logger, isShowLogs)
- VerifyMongodbInstallation(logger, isShowLogs)
+// ClientToolsHealthError returns an aggregated error if any fatal-tier bundle
+// has check failures, else nil. Used by the healthcheck endpoint.
+func ClientToolsHealthError() error {
+ results := CheckAllClientTools()
+
+ var msgs []string
+ for _, r := range results {
+ if !r.IsFatal {
+ continue
+ }
+
+ for _, err := range r.Errors {
+ msgs = append(msgs, fmt.Sprintf("%s %s: %s", r.Db, r.Version, err.Error()))
+ }
+ }
+
+ if len(msgs) == 0 {
+ return nil
+ }
+
+ return errors.New("client tools broken: " + strings.Join(msgs, "; "))
}
diff --git a/backend/internal/util/tools/mariadb.go b/backend/internal/util/tools/mariadb.go
index 2f314824..d61fdd41 100644
--- a/backend/internal/util/tools/mariadb.go
+++ b/backend/internal/util/tools/mariadb.go
@@ -2,11 +2,20 @@ package tools
import (
"fmt"
- "log/slog"
"path/filepath"
"strings"
)
+var mariadbClientVersions = []MariadbClientVersion{
+ MariadbClientLegacy,
+ MariadbClientModern,
+}
+
+var mariadbRequired = []string{
+ string(MariadbExecutableMariadbDump),
+ string(MariadbExecutableMariadb),
+}
+
type MariadbVersion string
const (
@@ -73,19 +82,24 @@ func getMariadbBinDir(clientVersion MariadbClientVersion) string {
)
}
-// VerifyMariadbInstallation is non-fatal — MariaDB support is optional.
-func VerifyMariadbInstallation(logger *slog.Logger, isShowLogs bool) {
- clientVersions := []MariadbClientVersion{MariadbClientLegacy, MariadbClientModern}
-
- required := []string{
- string(MariadbExecutableMariadbDump),
- string(MariadbExecutableMariadb),
+// checkMariadb verifies the legacy and modern MariaDB client bundles.
+// Non-fatal — missing bundles disable that client tier.
+func checkMariadb() []ToolCheckResult {
+ results := make([]ToolCheckResult, 0, len(mariadbClientVersions))
+
+ for _, cv := range mariadbClientVersions {
+ binDir := getMariadbBinDir(cv)
+
+ results = append(results, ToolCheckResult{
+ Db: "mariadb",
+ Version: string(cv),
+ BinDir: binDir,
+ Errors: checkBinDir(binDir, mariadbRequired),
+ IsFatal: false,
+ })
}
- for _, cv := range clientVersions {
- verifyBinDir(logger, "mariadb", string(cv), getMariadbBinDir(cv),
- required, false, isShowLogs)
- }
+ return results
}
// IsMariadbBackupVersionHigherThanRestoreVersion reports whether a backup
diff --git a/backend/internal/util/tools/mongodb.go b/backend/internal/util/tools/mongodb.go
index 6d63aaee..7e9aa9ee 100644
--- a/backend/internal/util/tools/mongodb.go
+++ b/backend/internal/util/tools/mongodb.go
@@ -2,11 +2,15 @@ package tools
import (
"fmt"
- "log/slog"
"path/filepath"
"regexp"
)
+var mongodbRequired = []string{
+ string(MongodbExecutableMongodump),
+ string(MongodbExecutableMongorestore),
+}
+
type MongodbVersion string
const (
@@ -35,15 +39,18 @@ func getMongodbBinDir() string {
return filepath.Join(AssetsToolsDir(), "mongodb", "bin")
}
-// VerifyMongodbInstallation is non-fatal — MongoDB support is optional.
-func VerifyMongodbInstallation(logger *slog.Logger, isShowLogs bool) {
- required := []string{
- string(MongodbExecutableMongodump),
- string(MongodbExecutableMongorestore),
- }
+// checkMongodb verifies the unified MongoDB Database Tools bundle. Non-fatal
+// — a missing bundle disables MongoDB support.
+func checkMongodb() []ToolCheckResult {
+ binDir := getMongodbBinDir()
- verifyBinDir(logger, "mongodb", "tools", getMongodbBinDir(),
- required, false, isShowLogs)
+ return []ToolCheckResult{{
+ Db: "mongodb",
+ Version: "tools",
+ BinDir: binDir,
+ Errors: checkBinDir(binDir, mongodbRequired),
+ IsFatal: false,
+ }}
}
// IsMongodbBackupVersionHigherThanRestoreVersion reports whether a backup
diff --git a/backend/internal/util/tools/mysql.go b/backend/internal/util/tools/mysql.go
index e2bfd96a..af3e9a46 100644
--- a/backend/internal/util/tools/mysql.go
+++ b/backend/internal/util/tools/mysql.go
@@ -2,11 +2,22 @@ package tools
import (
"fmt"
- "log/slog"
"path/filepath"
"strings"
)
+var mysqlVersions = []MysqlVersion{
+ MysqlVersion57,
+ MysqlVersion80,
+ MysqlVersion84,
+ MysqlVersion9,
+}
+
+var mysqlRequired = []string{
+ string(MysqlExecutableMysqldump),
+ string(MysqlExecutableMysql),
+}
+
type MysqlVersion string
const (
@@ -38,25 +49,24 @@ func getMysqlBinDir(version MysqlVersion) string {
)
}
-// VerifyMysqlInstallation is non-fatal — MySQL support is optional, so a
-// missing version warns rather than exiting.
-func VerifyMysqlInstallation(logger *slog.Logger, isShowLogs bool) {
- versions := []MysqlVersion{
- MysqlVersion57,
- MysqlVersion80,
- MysqlVersion84,
- MysqlVersion9,
- }
+// checkMysql verifies every supported MySQL version's bin directory. MySQL
+// is non-fatal — a missing bundle disables that version's support.
+func checkMysql() []ToolCheckResult {
+ results := make([]ToolCheckResult, 0, len(mysqlVersions))
- required := []string{
- string(MysqlExecutableMysqldump),
- string(MysqlExecutableMysql),
- }
+ for _, v := range mysqlVersions {
+ binDir := getMysqlBinDir(v)
- for _, v := range versions {
- verifyBinDir(logger, "mysql", string(v), getMysqlBinDir(v),
- required, false, isShowLogs)
+ results = append(results, ToolCheckResult{
+ Db: "mysql",
+ Version: string(v),
+ BinDir: binDir,
+ Errors: checkBinDir(binDir, mysqlRequired),
+ IsFatal: false,
+ })
}
+
+ return results
}
// IsMysqlBackupVersionHigherThanRestoreVersion reports whether a backup
diff --git a/backend/internal/util/tools/postgresql.go b/backend/internal/util/tools/postgresql.go
index 0302dfcc..34fd36be 100644
--- a/backend/internal/util/tools/postgresql.go
+++ b/backend/internal/util/tools/postgresql.go
@@ -2,12 +2,26 @@ package tools
import (
"fmt"
- "log/slog"
"path/filepath"
"runtime"
"strings"
)
+var postgresqlVersions = []PostgresqlVersion{
+ PostgresqlVersion12,
+ PostgresqlVersion13,
+ PostgresqlVersion14,
+ PostgresqlVersion15,
+ PostgresqlVersion16,
+ PostgresqlVersion17,
+ PostgresqlVersion18,
+}
+
+var postgresqlRequired = []string{
+ string(PostgresqlExecutablePgDump),
+ string(PostgresqlExecutablePsql),
+}
+
// GetPostgresqlExecutable returns the absolute path to a PostgreSQL client
// binary for the given version (e.g. pg_dump, pg_restore, psql).
func GetPostgresqlExecutable(
@@ -34,28 +48,25 @@ func getPostgresqlBinDir(version PostgresqlVersion) string {
)
}
-// VerifyPostgresqlInstallation is fatal — the app needs every PG version
-// because we read the version from each managed database.
-func VerifyPostgresqlInstallation(logger *slog.Logger, isShowLogs bool) {
- versions := []PostgresqlVersion{
- PostgresqlVersion12,
- PostgresqlVersion13,
- PostgresqlVersion14,
- PostgresqlVersion15,
- PostgresqlVersion16,
- PostgresqlVersion17,
- PostgresqlVersion18,
- }
+// checkPostgresql verifies every supported PG version's bin directory. PG is
+// fatal-tier — the app reads the version from each managed database and must
+// be able to invoke the matching client.
+func checkPostgresql() []ToolCheckResult {
+ results := make([]ToolCheckResult, 0, len(postgresqlVersions))
- required := []string{
- string(PostgresqlExecutablePgDump),
- string(PostgresqlExecutablePsql),
- }
+ for _, v := range postgresqlVersions {
+ binDir := getPostgresqlBinDir(v)
- for _, v := range versions {
- verifyBinDir(logger, "postgresql", string(v), getPostgresqlBinDir(v),
- required, true, isShowLogs)
+ results = append(results, ToolCheckResult{
+ Db: "postgresql",
+ Version: string(v),
+ BinDir: binDir,
+ Errors: checkBinDir(binDir, postgresqlRequired),
+ IsFatal: true,
+ })
}
+
+ return results
}
// EscapePgpassField escapes special characters for the .pgpass file format.