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

View file

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

View file

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

View file

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