Chaged static sql instance to dynamic instance
This commit is contained in:
parent
6f95fedbc1
commit
a23791daa5
3 changed files with 8 additions and 14 deletions
|
|
@ -49,8 +49,7 @@ func (azure AzureFileStorage) upload(fileName string){
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
fmt.Printf("[%s] Starting upload to Azure File Share...\n", strings.Trim(filepath.Base(fileName), ".bak"))
|
fmt.Printf("[%s] Starting upload to Azure File Share...\n", strings.Trim(filepath.Base(fileName), ".bak"))
|
||||||
//TODO Remove Hardcoded SQL Instance
|
SQL.NewLogEntry(SQL.GetSQLInstance(), uuid.New(), SQL.LogInfo, filepath.Base(fileName), SQL.SQLStage_Upload, SQL.REMOTE_AZURE_FILE, "Starting upload.", time.Now())
|
||||||
SQL.NewLogEntry(SQL.GetMariaDBInstance(), uuid.New(), SQL.LogInfo, filepath.Base(fileName), SQL.SQLStage_Upload, SQL.REMOTE_AZURE_FILE, "Starting upload.", time.Now())
|
|
||||||
|
|
||||||
err = azfile.UploadFileToAzureFile(ctx, file, fileURL,
|
err = azfile.UploadFileToAzureFile(ctx, file, fileURL,
|
||||||
azfile.UploadToAzureFileOptions{
|
azfile.UploadToAzureFileOptions{
|
||||||
|
|
@ -63,8 +62,7 @@ func (azure AzureFileStorage) upload(fileName string){
|
||||||
}})
|
}})
|
||||||
|
|
||||||
fmt.Printf("[%s] Upload finished.\n", strings.Trim(filepath.Base(fileName), ".bak"))
|
fmt.Printf("[%s] Upload finished.\n", strings.Trim(filepath.Base(fileName), ".bak"))
|
||||||
//TODO Remove Hardcoded SQL Instance
|
SQL.NewLogEntry(SQL.GetSQLInstance(), uuid.New(), SQL.LogInfo, filepath.Base(fileName), SQL.SQLStage_Upload, SQL.REMOTE_AZURE_FILE, "Finished upload.", time.Now())
|
||||||
SQL.NewLogEntry(SQL.GetMariaDBInstance(), uuid.New(), SQL.LogInfo, filepath.Base(fileName), SQL.SQLStage_Upload, SQL.REMOTE_AZURE_FILE, "Finished upload.", time.Now())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func readConfig() []byte {
|
func readConfig() []byte {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package main
|
package Tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
|
|
@ -32,8 +32,7 @@ func CreateBakFile(filename string, folderPath string, destinationPath string) s
|
||||||
logger.Fatal(err)
|
logger.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Remove Hardcoded SQL Instance
|
SQL.NewLogEntry(SQL.GetSQLInstance(), uuid.New(), SQL.LogInfo, filepath.Base(folderPath), SQL.SQLStage_Compress, SQL.REMOTE_NONE, "File successfully written.", time.Now())
|
||||||
SQL.NewLogEntry(SQL.GetMariaDBInstance(), uuid.New(), SQL.LogInfo, filepath.Base(folderPath), SQL.SQLStage_Compress, SQL.REMOTE_NONE, "File successfully written.", time.Now())
|
|
||||||
|
|
||||||
|
|
||||||
return fileName
|
return fileName
|
||||||
|
|
@ -47,8 +46,7 @@ func compress(folderPath string, buf io.Writer){
|
||||||
tw := tar.NewWriter(zr)
|
tw := tar.NewWriter(zr)
|
||||||
|
|
||||||
fmt.Printf("[%s] Start compression...\n", filepath.Base(folderPath))
|
fmt.Printf("[%s] Start compression...\n", filepath.Base(folderPath))
|
||||||
//TODO Remove Hardcoded SQL Instance
|
SQL.NewLogEntry(SQL.GetSQLInstance(), uuid.New(), SQL.LogInfo, filepath.Base(folderPath), SQL.SQLStage_Compress, SQL.REMOTE_NONE, "Start compression", time.Now())
|
||||||
SQL.NewLogEntry(SQL.GetMariaDBInstance(), uuid.New(), SQL.LogInfo, filepath.Base(folderPath), SQL.SQLStage_Compress, SQL.REMOTE_NONE, "Start compression", time.Now())
|
|
||||||
filepath.Walk(folderPath, func(file string, fi os.FileInfo, err error) error {
|
filepath.Walk(folderPath, func(file string, fi os.FileInfo, err error) error {
|
||||||
header, err := tar.FileInfoHeader(fi, file)
|
header, err := tar.FileInfoHeader(fi, file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -86,6 +84,5 @@ func compress(folderPath string, buf io.Writer){
|
||||||
|
|
||||||
|
|
||||||
fmt.Printf("[%s] Compression Done.\n", filepath.Base(folderPath))
|
fmt.Printf("[%s] Compression Done.\n", filepath.Base(folderPath))
|
||||||
//TODO Remove Hardcoded SQL Instance
|
SQL.NewLogEntry(SQL.GetSQLInstance(), uuid.New(), SQL.LogInfo, filepath.Base(folderPath), SQL.SQLStage_Compress, SQL.REMOTE_NONE, "Compression complete.", time.Now())
|
||||||
SQL.NewLogEntry(SQL.GetMariaDBInstance(), uuid.New(), SQL.LogInfo, filepath.Base(folderPath), SQL.SQLStage_Compress, SQL.REMOTE_NONE, "Compression complete.", time.Now())
|
|
||||||
}
|
}
|
||||||
5
main.go
5
main.go
|
|
@ -19,13 +19,12 @@ func main(){
|
||||||
storage := StorageTypes.CheckStorageType(backupItem.StorageType)
|
storage := StorageTypes.CheckStorageType(backupItem.StorageType)
|
||||||
destPath := checkTmpPath(config, backupItem.CreateLocalBackup)
|
destPath := checkTmpPath(config, backupItem.CreateLocalBackup)
|
||||||
|
|
||||||
bakFile := CreateBakFile(backupItem.BackupName + getTimeSuffix(), backupItem.FolderPath, destPath)
|
bakFile := Tools.CreateBakFile(backupItem.BackupName + getTimeSuffix(), backupItem.FolderPath, destPath)
|
||||||
StorageTypes.UploadFile(storage, destPath + string(os.PathSeparator) + bakFile)
|
StorageTypes.UploadFile(storage, destPath + string(os.PathSeparator) + bakFile)
|
||||||
|
|
||||||
if !backupItem.CreateLocalBackup {
|
if !backupItem.CreateLocalBackup {
|
||||||
_ = os.Remove(destPath + string(os.PathSeparator) + bakFile)
|
_ = os.Remove(destPath + string(os.PathSeparator) + bakFile)
|
||||||
//TODO Remove Hardcoded SQL Instance
|
SQL.NewLogEntry(SQL.GetSQLInstance(), uuid.New(), SQL.LogInfo, backupItem.BackupName, SQL.SQLStage_DeleteTmp, SQL.REMOTE_NONE, "Deleted tmp file" ,time.Now())
|
||||||
SQL.NewLogEntry(SQL.GetMariaDBInstance(), uuid.New(), SQL.LogInfo, backupItem.BackupName, SQL.SQLStage_DeleteTmp, SQL.REMOTE_NONE, "Deleted tmp file" ,time.Now())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue