feat: add migrate database from a source to a target databse

fix: gpg encrypt permission warning message, update Kubernetes deployment example
This commit is contained in:
Jonas Kaninda
2024-08-30 19:58:12 +02:00
parent 8fb008151c
commit 662b73579d
18 changed files with 497 additions and 157 deletions

View File

@@ -1,9 +1,11 @@
package pkg
import (
"bytes"
"fmt"
"github.com/jkaninda/mysql-bkup/utils"
"os"
"os/exec"
"path/filepath"
"time"
)
@@ -96,3 +98,24 @@ func deleteTemp() {
utils.Info("Deleting %s ... done", tmpPath)
}
}
// TestDatabaseConnection tests the database connection
func testDatabaseConnection(db *dbConfig) {
utils.Info("Connecting to %s database ...", db.dbName)
cmd := exec.Command("mysql", "-h", db.dbHost, "-P", db.dbPort, "-u", db.dbUserName, "--password="+db.dbPassword, db.dbName, "-e", "quit")
// Capture the output
var out bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &out
err := cmd.Run()
if err != nil {
utils.Error("Error testing database connection: %v\nOutput: %s", err, out.String())
os.Exit(1)
}
utils.Info("Successfully connected to %s database", db.dbName)
}