From 4a19290e21ad2d676983a466f2e63790654c9ac1 Mon Sep 17 00:00:00 2001 From: LobbyLobster Date: Mon, 14 Oct 2024 13:57:20 +0300 Subject: [PATCH] mssql backup minor fixes --- backup/backup.go | 3 +++ backup/mssql_linux.go | 3 --- backup/mssql_windows.go | 5 +---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/backup/backup.go b/backup/backup.go index 9d0aa3e..28d801b 100644 --- a/backup/backup.go +++ b/backup/backup.go @@ -141,6 +141,9 @@ func Backup() { } } } + if params.Database == "mssql" { + mssqlDB.Close() + } } func uploadWhileDumping(db string) { diff --git a/backup/mssql_linux.go b/backup/mssql_linux.go index fc289ce..ac62c10 100644 --- a/backup/mssql_linux.go +++ b/backup/mssql_linux.go @@ -84,7 +84,6 @@ func dumpMSSQLDB(dbName, dst string) (string, string, error) { if err := os.MkdirAll(filepath.Dir(dumpPath), 0770); err != nil { logger.Error("Couldn't create parent directories at backup destination " + dst + ". Name: " + name + " - Error: " + err.Error()) - mssqlDB.Close() return "", "", err } query := "BACKUP DATABASE [" + dbName + "]" + @@ -103,9 +102,7 @@ func dumpMSSQLDB(dbName, dst string) (string, string, error) { `, )*/ if err != nil { logger.Error("Couldn't back up database: " + dbName + " - Error: " + err.Error()) - mssqlDB.Close() return "", "", err } - mssqlDB.Close() return dumpPath, name, nil } diff --git a/backup/mssql_windows.go b/backup/mssql_windows.go index 49f528e..adeefb2 100644 --- a/backup/mssql_windows.go +++ b/backup/mssql_windows.go @@ -34,7 +34,7 @@ func InitializeMSSQL() { logger.Fatal("Remote should be enabled when backing up MSSQL databases.") return } - connString := fmt.Sprintf("server=%s;user id=%s;password=%s;port=%s", + connString := fmt.Sprintf("server=%s;user id=%s;password=%s;port=%s;encrypt=disable;trustServerCertificate=true", host, user, password, port) // Create connection pool @@ -87,7 +87,6 @@ func dumpMSSQLDB(dbName, dst string) (string, string, error) { if err := os.MkdirAll(filepath.Dir(dumpPath), 0770); err != nil { logger.Error("Couldn't create parent directories at backup destination " + dst + ". Name: " + name + " - Error: " + err.Error()) - mssqlDB.Close() return "", "", err } if err := acl.Apply( @@ -115,9 +114,7 @@ func dumpMSSQLDB(dbName, dst string) (string, string, error) { `, )*/ if err != nil { logger.Error("Couldn't back up database: " + dbName + " - Error: " + err.Error()) - mssqlDB.Close() return "", "", err } - mssqlDB.Close() return dumpPath, name, nil }