Merge branch 'develop'

This commit is contained in:
netbenix 2021-12-07 18:50:07 +01:00
commit 636101605b
4 changed files with 20 additions and 7 deletions

View file

@ -3,8 +3,8 @@
Please keep in mind that this project is WIP.
## What can it do?
- Backup you stuff via a dynamic configuration (done!)
- Log the Backup progress to a database (in progress)
- Backup you stuff via a dynamic configuration
- Log the Backup progress to a database
- Upload the files to a remote storage of your choice (see [Storage Types](#storage-types))
@ -39,6 +39,7 @@ Please keep in mind that this project is WIP.
|---------------------|:----------------:|------------------------------------------------|
| localBackupPath | string | Path where local backups are stored |
| **sqlConfig** | ---------------- | ---------------------------------------------- |
| enableSQL | boolean | Enable/Disables the SQL entries
| sqlType | string | See [DatabaseTypes](#database-types) |
| sql-address | string | Address to the SQL Server |
| sql-port | uint16 | SQL Server Port |

View file

@ -13,20 +13,31 @@ type SQLService interface {
}
func CreateDefaultTables(sqlService SQLService){
sqlService.createDefaultTables()
config := Tools.GetConfig()
if config.SQLConfig.EnableSQL{
sqlService.createDefaultTables()
}
}
func NewLogEntry(sqlService SQLService, uuid uuid.UUID, logType LogType, backupName string, stage SQLStage, storageType RemoteStorageType, description string, timestamp time.Time){
sqlService.newLogEntry(uuid, logType, backupName, stage, storageType, description, timestamp)
config := Tools.GetConfig()
if config.SQLConfig.EnableSQL{
sqlService.newLogEntry(uuid, logType, backupName, stage, storageType, description, timestamp)
}
}
func NewBackupEntry(sqlService SQLService, backupName string, lastBackup time.Time, localBackup bool, filePath string, storageType RemoteStorageType, remotePath string){
sqlService.newBackupEntry(backupName, lastBackup, localBackup, filePath, storageType, remotePath)
config := Tools.GetConfig()
if config.SQLConfig.EnableSQL{
sqlService.newBackupEntry(backupName, lastBackup, localBackup, filePath, storageType, remotePath)
}
}
func GetSQLInstance() SQLService{
config := Tools.GetConfig()
if !config.SQLConfig.EnableSQL { return nil }
switch config.SQLConfig.SqlType {
case "mariadb": {return GetMariaDBInstance(config)}
}

View file

@ -9,7 +9,8 @@ import (
type Config struct {
LocalBackupPath string `json:"localBackupPath"`
SQLConfig struct{
SqlType string `json:"sqlType"`
EnableSQL bool `json:"enableSQL"`
SqlType string `json:"sqlType"`
SqlAddress string `json:"sql-address"`
SqlPort uint16 `json:"sql-port"`
Database string `json:"database"`

View file

@ -1,7 +1,7 @@
{
"localBackupPath": "",
"sqlConfig": {
"sqlType": "",
"enableSQL": false,
"sql-address": "",
"sql-port": 0,
"database": "",