refactor: move backup, restore, s3fs tasks in pkg folder

This commit is contained in:
2024-01-19 05:31:30 +01:00
parent 078d57fc0d
commit 164d8eda77
10 changed files with 438 additions and 269 deletions

View File

@@ -10,6 +10,7 @@ import (
"fmt"
"io/fs"
"os"
"os/exec"
)
func Info(v ...any) {
@@ -70,3 +71,16 @@ func IsDirEmpty(name string) (bool, error) {
}
return true, nil
}
// TestDatabaseConnection tests the database connection
func TestDatabaseConnection() {
Info("Testing database connection...")
// Test database connection
cmd := exec.Command("mysql", "-h", os.Getenv("DB_HOST"), "-P", os.Getenv("DB_PORT"), "-u", os.Getenv("DB_USERNAME"), "--password="+os.Getenv("DB_PASSWORD"), os.Getenv("DB_NAME"), "-e", "quit")
err := cmd.Run()
if err != nil {
Fatal("Error testing database connection:", err)
}
}