From c4967a97b2b7fb1d6be9b0be6ba145bc8d266d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieliski?= Date: Thu, 17 Oct 2024 10:20:22 +0200 Subject: [PATCH] WIP: backup fix --- WebAPI/Controllers/AdminController.cs | 9 +++++---- WebAPI/appsettings.Development.json | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/WebAPI/Controllers/AdminController.cs b/WebAPI/Controllers/AdminController.cs index 3344a92..4c96436 100644 --- a/WebAPI/Controllers/AdminController.cs +++ b/WebAPI/Controllers/AdminController.cs @@ -41,6 +41,7 @@ public class AdminController : Controller const string formatMediaName = $"DatabaseToolkitBackup_{databaseName}"; const string formatName = $"Full Backup of {databaseName}"; + /* var connection = new SqlConnection(_configuration.GetConnectionString("SQLDatabase")); const string sql = """ @@ -62,15 +63,15 @@ public class AdminController : Controller command.Parameters.AddWithValue("@formatName", formatName); command.ExecuteNonQuery(); - +*/ var body = new Google.Apis.Drive.v3.Data.File { Name = Path.GetFileName(localDatabasePath), - Parents = new List { _configuration["GDriveBackupDirectory"] }, + Parents = new List { "1ANm0pokPFgBw7vIaxLgDWXqznl3UjVvJ" }, MimeType = "application/octet-stream" }; - var fsSource = new FileStream(localDatabasePath, FileMode.Open, FileAccess.Read); + var fsSource = new FileStream("/Users/mz/Projects/Diuna/diunabi-morska-9.bak", FileMode.Open, FileAccess.Read); if (_googleDriveHelper.Service is null) { @@ -79,7 +80,7 @@ public class AdminController : Controller var request = _googleDriveHelper.Service.Files.Create(body, fsSource, body.MimeType); request.Fields = "id"; - + request.Upload(); _logsController.AddEntry(new LogEntry diff --git a/WebAPI/appsettings.Development.json b/WebAPI/appsettings.Development.json index 86d3b65..b025ae4 100644 --- a/WebAPI/appsettings.Development.json +++ b/WebAPI/appsettings.Development.json @@ -21,7 +21,7 @@ "appLogsFile": "13PuDvS3_HAYoSLOCgKexzlzIDLUilkApUF8QiJMTae0", "apiLocalUrl": "localhost:5400", "dbBackupFile": "/home/mz/backups/diunabi-morska", - "GDriveBackupDirectory": "1FEcdtVcF2cuqCROdq-vlBNs__th1M8_P", + "GDriveBackupDirectory": "1ANm0pokPFgBw7vIaxLgDWXqznl3UjVvJ", "Kestrel": { "Endpoints": { "Http": {