This commit is contained in:
@@ -22,7 +22,7 @@ namespace AyaNova.Biz
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
public static async Task DoWorkAsync(AyContext ct, bool OnDemand = false)
|
||||
public static async Task DoWorkAsync(bool OnDemand = false)
|
||||
{
|
||||
if (BackupIsRunning) return;
|
||||
if (!OnDemand)
|
||||
@@ -41,7 +41,7 @@ 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);
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, $"Starting backup job {(OnDemand ? "manual / on demand" : "scheduled") } ");
|
||||
log.LogDebug("Backup starting");
|
||||
var DemandFileNamePrepend=OnDemand?"manual-":string.Empty;
|
||||
//*************
|
||||
@@ -50,7 +50,7 @@ namespace AyaNova.Biz
|
||||
//this is valid on windows
|
||||
//C:\data\code\PostgreSQLPortable_12.0\App\PgSQL\bin\pg_dump --dbname=postgresql://postgres:raven@127.0.0.1:5432/AyaNova -Fc > huge_new.backup
|
||||
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, $"Data backup starting", ct);
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, $"Data backup starting");
|
||||
Npgsql.NpgsqlConnectionStringBuilder PostgresConnectionString = new Npgsql.NpgsqlConnectionStringBuilder(ServerBootConfig.AYANOVA_DB_CONNECTION);
|
||||
var DBNameParameter = $"--dbname=postgresql://{PostgresConnectionString.Username}:{PostgresConnectionString.Password}@{PostgresConnectionString.Host}:{PostgresConnectionString.Port}/{PostgresConnectionString.Database}";
|
||||
|
||||
@@ -71,19 +71,19 @@ namespace AyaNova.Biz
|
||||
}
|
||||
else
|
||||
{
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, $"Error during data backup \"{Result}\"", ct);
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, $"Error during data backup \"{Result}\"");
|
||||
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);
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, $"Attachments backup starting");
|
||||
FileUtil.BackupAttachments(DemandFileNamePrepend);
|
||||
}
|
||||
|
||||
//PRUNE DATA BACKUP SETS NOT KEPT
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, $"Pruning old backup sets", ct);
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, $"Pruning old backup sets");
|
||||
FileUtil.DatabaseBackupCleanUp(ServerGlobalOpsSettingsCache.Backup.BackupSetsToKeep);
|
||||
|
||||
//v.next - COPY TO ONLINE STORAGE
|
||||
@@ -92,8 +92,8 @@ namespace AyaNova.Biz
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, "Backup failed with errors:", ct);
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, ExceptionUtil.ExtractAllExceptionMessages(ex), ct);
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, "Backup failed with errors:");
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, ExceptionUtil.ExtractAllExceptionMessages(ex));
|
||||
log.LogError(ex, "Backup failed");
|
||||
throw ex;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ namespace AyaNova.Biz
|
||||
ServerGlobalOpsSettingsCache.SetNextBackup();
|
||||
apiServerState.ResumePriorState();
|
||||
BackupIsRunning = false;
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, $"Backup - fully complete, server re-opened", ct);
|
||||
await JobsBiz.LogJobAsync(Guid.Empty, $"Backup - fully complete, server re-opened");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,9 +118,9 @@ namespace AyaNova.Biz
|
||||
foreach (OpsJob j in jobs)
|
||||
{
|
||||
//OPSMETRIC
|
||||
await JobsBiz.LogJobAsync(j.GId, "Job took too long to run - setting to failed", ct);
|
||||
await JobsBiz.LogJobAsync(j.GId, "Job took too long to run - setting to failed");
|
||||
log.LogError($"Job found job stuck in running status and set to failed: deadline={dtRunningDeadline.ToString()}, jobId={j.GId.ToString()}, jobname={j.Name}, jobtype={j.JobType.ToString()}, jobObjectType={j.ObjectType.ToString()}, jobObjectId={j.ObjectId.ToString()}");
|
||||
await JobsBiz.UpdateJobStatusAsync(j.GId, JobStatus.Failed, ct);
|
||||
await JobsBiz.UpdateJobStatusAsync(j.GId, JobStatus.Failed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user