Started implementing SQL Logs.

Only MariaDB yet. Interface usage comes soon.
This commit is contained in:
netbenix 2021-11-22 21:29:19 +01:00
parent 077459c6e0
commit 33b44a6ea5
3 changed files with 27 additions and 4 deletions

12
main.go
View file

@ -1,25 +1,31 @@
package main
import (
"github.com/google/uuid"
"os"
"scabiosa/Logging"
"scabiosa/SQL"
"scabiosa/StorageTypes"
"scabiosa/Tools"
"time"
)
func main(){
config := GetConfig()
config := Tools.GetConfig()
SQL.CreateDefaultTables(SQL.GetMariaDBInstance())
for _, backupItem := range config.FolderToBackup{
storage := StorageTypes.CheckStorageType(backupItem.StorageType)
destPath := checkTmpPath(config, backupItem.CreateLocalBackup)
bakFile := CreateBakFile(backupItem.BackupName + getTimeSuffix(), backupItem.FolderPath, destPath)
StorageTypes.UploadFile(storage, destPath + string(os.PathSeparator) + bakFile)
if !backupItem.CreateLocalBackup {
_ = os.Remove(destPath + string(os.PathSeparator) + bakFile)
//TODO Remove Hardcoded SQL Instance
SQL.NewLogEntry(SQL.GetMariaDBInstance(), uuid.New(), SQL.LogInfo, backupItem.BackupName, SQL.SQLStage_DeleteTmp, SQL.REMOTE_NONE, "Deleted tmp file" ,time.Now())
}
}
@ -33,7 +39,7 @@ func getTimeSuffix() string{
return "_" + currTime.Format("02-01-2006_15-04")
}
func checkTmpPath(config Config, createLocalBackup bool) string{
func checkTmpPath(config Tools.Config, createLocalBackup bool) string{
logger := Logging.DetailedLogger("mainThread", "checkTmpPath")
if !createLocalBackup{
if _, err := os.Stat("tmp"); os.IsNotExist(err) {