diff --git a/server/AyaNova/generator/CoreJobBackup.cs b/server/AyaNova/generator/CoreJobBackup.cs index 94f9f214..837fafb4 100644 --- a/server/AyaNova/generator/CoreJobBackup.cs +++ b/server/AyaNova/generator/CoreJobBackup.cs @@ -25,28 +25,14 @@ namespace AyaNova.Biz public static async Task DoWorkAsync(AyContext ct, bool OnDemand = false) { if (BackupIsRunning) return; - //testing FileUtil.DatabaseBackupCleanUp(ServerGlobalOpsSettingsCache.Backup.BackupSetsToKeep); - //get NOW in utc - DateTime utcNow = DateTime.UtcNow; if (!OnDemand) { - log.LogTrace("Checking if backup should run"); - - //what time should we backup today? - // DateTime todayBackupTime = new DateTime(utcNow.Year, utcNow.Month, utcNow.Day, ServerGlobalOpsSettingsCache.Backup.BackupTime.Hour, ServerGlobalOpsSettingsCache.Backup.BackupTime.Minute, 0, DateTimeKind.Utc);//first start with NOW - //Are we there yet? - if (utcNow < ServerGlobalOpsSettingsCache.NextBackup) + log.LogTrace("Checking if backup should run"); + if (DateTime.UtcNow < ServerGlobalOpsSettingsCache.NextBackup) { - log.LogTrace("Not past backup time yet"); return;//nope - } - // //Yes, we've passed into the backup window time, but that's also true if we just ran the backup as well so - // //need to check for that as well... - // //Has last backup run more than 24 hours ago? - // if (ServerGlobalOpsSettingsCache.Backup.LastBackup > utcNow.AddHours(-24)) - // { - // log.LogTrace("Hasn't been 24 hours since last backup yet"); return;//nope, so we have already run today's backup - // } - //Ok, we're into backup time and it's been more than 24 hours since it last ran so let's do this... + log.LogTrace("Not past backup time yet"); + return; + } } AyaNova.Api.ControllerHelpers.ApiServerState apiServerState = null; try @@ -55,14 +41,9 @@ namespace AyaNova.Biz //LOCK DOWN SERVER apiServerState = (AyaNova.Api.ControllerHelpers.ApiServerState)ServiceProviderProvider.Provider.GetService(typeof(AyaNova.Api.ControllerHelpers.ApiServerState)); apiServerState.SetClosed("BACKUP RUNNING"); - await JobsBiz.LogJobAsync(Guid.Empty, $"Starting backup job {(OnDemand ? "manual / on demand" : "scheduled") } ", ct); - log.LogDebug("Backup starting"); - - var DemandFileNamePrepend=OnDemand?"manual-":string.Empty; - //************* //DO DATA BACKUP //build command @@ -94,24 +75,19 @@ namespace AyaNova.Biz log.LogError($"BACKUP ERROR: {Result}"); } - //DO FILE BACKUP IF ATTACHMENTS BACKED UP if (ServerGlobalOpsSettingsCache.Backup.BackupAttachments) { await JobsBiz.LogJobAsync(Guid.Empty, $"Attachments backup starting", ct); FileUtil.BackupAttachments(DemandFileNamePrepend); - } //PRUNE DATA BACKUP SETS NOT KEPT await JobsBiz.LogJobAsync(Guid.Empty, $"Pruning old backup sets", ct); FileUtil.DatabaseBackupCleanUp(ServerGlobalOpsSettingsCache.Backup.BackupSetsToKeep); - //v.next - COPY TO ONLINE STORAGE - - //*************** - + //*************** log.LogDebug("Backup completed"); } catch (Exception ex) diff --git a/server/AyaNova/util/ServerGlobalOpsSettingsCache.cs b/server/AyaNova/util/ServerGlobalOpsSettingsCache.cs index a6bad1cf..a2fb432b 100644 --- a/server/AyaNova/util/ServerGlobalOpsSettingsCache.cs +++ b/server/AyaNova/util/ServerGlobalOpsSettingsCache.cs @@ -11,11 +11,8 @@ namespace AyaNova.Util /// internal static class ServerGlobalOpsSettingsCache { - internal static GlobalOpsBackupSettings Backup { get; set; } internal static DateTime NextBackup { get; set; } - - /// /// Populate and / or create the settings /// @@ -31,7 +28,6 @@ namespace AyaNova.Util } NextBackup = FileUtil.MostRecentAutomatedBackupFileDate(); SetNextBackup(); - } internal static void SetNextBackup() @@ -53,6 +49,5 @@ namespace AyaNova.Util } } - }//eoc }//eons \ No newline at end of file