Skip to content

Commit

Permalink
enabled some alarms
Browse files Browse the repository at this point in the history
  • Loading branch information
LobbyLobster committed Jul 23, 2024
1 parent ce58e93 commit 4c3ed52
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
11 changes: 6 additions & 5 deletions backup/mssql_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"database/sql"
"fmt"
"log"
"monodb-backup/notify"
"os"
"path/filepath"
"strconv"
Expand All @@ -26,7 +27,7 @@ func InitializeMSSQL() {
user = params.Remote.User
password = params.Remote.Password
} else {
// notify.SendAlarm("Remote should be enabled when backing up MSSQL databases.", true)
notify.SendAlarm("Remote should be enabled when backing up MSSQL databases.", true)
logger.Fatal("Remote should be enabled when backing up MSSQL databases.")
return
}
Expand Down Expand Up @@ -86,12 +87,12 @@ func dumpMSSQLDB(dbName, dst string) (string, string, error) {
mssqlDB.Close()
return "", "", err
}
query := "BACKUP DATABASE [" + dbName + "]" +
" TO DISK = '" + dumpPath + "'" +
" WITH COMPRESSION;"

ctx := context.Background()
_, err := mssqlDB.ExecContext(ctx,
"BACKUP DATABASE "+dbName+
" TO DISK = '"+dumpPath+"'"+
" WITH COMPRESSION;") /* `
_, err := mssqlDB.ExecContext(ctx, query) /* `
BACKUP DATABASE `+dbName+`
TO DISK = '`+dumpPath+`'
WITH FORMAT, INIT, NAME = 'Full Backup of `+dbName+`';
Expand Down
3 changes: 2 additions & 1 deletion backup/mssql_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"database/sql"
"fmt"
"log"
"monodb-backup/notify"
"os"
"path/filepath"
"strconv"
Expand All @@ -29,7 +30,7 @@ func InitializeMSSQL() {
user = params.Remote.User
password = params.Remote.Password
} else {
// notify.SendAlarm("Remote should be enabled when backing up MSSQL databases.", true)
notify.SendAlarm("Remote should be enabled when backing up MSSQL databases.", true)
logger.Fatal("Remote should be enabled when backing up MSSQL databases.")
return
}
Expand Down
2 changes: 1 addition & 1 deletion backup/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func getMySQLList() []string {
cmd := exec.Command("/usr/bin/mysql", mysqlArgs...)
out, err := cmd.Output()
if err != nil {
// notify.SendAlarm("Couldn't get the list of databases - Error: "+string(out), true)
notify.SendAlarm("Couldn't get the list of databases - Error: "+string(out), true)
logger.Fatal("Couldn't get the list of databases - Error: " + string(out))
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion backup/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"io"
"monodb-backup/config"
"monodb-backup/notify"
"os"
"os/exec"
"path/filepath"
Expand All @@ -29,7 +30,7 @@ func getPSQLList() []string {
cmd.Stderr = &stderr
out, err := cmd.Output()
if err != nil {
// notify.SendAlarm("Couldn't get the list of databases - Error: "+string(out), true)
notify.SendAlarm("Couldn't get the list of databases - Error: "+string(out), true)
logger.Fatal("Couldn't get the list of databases - Error: " + string(out) + "\nError: " + stderr.String())
return nil
}
Expand Down

0 comments on commit 4c3ed52

Please sign in to comment.