Backup
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
using AyaNova.Util;
|
using AyaNova.Util;
|
||||||
@@ -53,14 +51,15 @@ namespace AyaNova.Biz
|
|||||||
//*************
|
//*************
|
||||||
|
|
||||||
//DO DATA BACKUP
|
//DO DATA BACKUP
|
||||||
log.LogInformation("SIMULATED BACKUP RUNNING NOW - TORA TORA TORA!");
|
log.LogInformation("BACKUP STUB: DATA BACKUP RUNNING NOW - TORA TORA TORA!");
|
||||||
log.LogInformation($"dbdump path: {ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH}");
|
log.LogInformation($"dbdump path: {ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH}");
|
||||||
|
|
||||||
//DO FILE BACKUP IF ATTACHMENTS BACKED UP
|
//DO FILE BACKUP IF ATTACHMENTS BACKED UP
|
||||||
|
log.LogInformation("BACKUP STUB: ATTACHMENTS BACKUP RUNNING NOW");
|
||||||
//OPNE SERVER
|
|
||||||
|
|
||||||
//PRUNE BACKUP SETS NOT KEPT
|
//PRUNE BACKUP SETS NOT KEPT
|
||||||
|
log.LogInformation("BACKUP STUB: PRUNING RUNNING NOW");
|
||||||
|
|
||||||
|
|
||||||
//v.next - COPY TO ONLINE STORAGE
|
//v.next - COPY TO ONLINE STORAGE
|
||||||
|
|
||||||
@@ -87,60 +86,6 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static async Task sweepAsync(AyContext ct, DateTime dtDeleteCutoff, JobStatus jobStatus)
|
|
||||||
{
|
|
||||||
|
|
||||||
//Get the deleteable succeeded jobs list
|
|
||||||
var jobs = await ct.OpsJob
|
|
||||||
.AsNoTracking()
|
|
||||||
.Where(z => z.Created < dtDeleteCutoff && z.JobStatus == jobStatus)
|
|
||||||
.OrderBy(z => z.Created)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
log.LogTrace($"SweepAsync processing: cutoff={dtDeleteCutoff.ToString()}, for {jobs.Count.ToString()} jobs of status {jobStatus.ToString()}");
|
|
||||||
|
|
||||||
foreach (OpsJob j in jobs)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await JobsBiz.DeleteJobAndLogAsync(j.GId, ct);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
log.LogError(ex, "sweepAsync exception calling JobsBiz.DeleteJobAndLogAsync");
|
|
||||||
//for now just throw it but this needs to be removed when logging added and better handling
|
|
||||||
throw (ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Kill jobs that have been stuck in "running" state for too long
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ct"></param>
|
|
||||||
/// <param name="dtRunningDeadline"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static async Task killStuckJobsAsync(AyContext ct, DateTime dtRunningDeadline)
|
|
||||||
{
|
|
||||||
//Get the deleteable succeeded jobs list
|
|
||||||
var jobs = await ct.OpsJob
|
|
||||||
.AsNoTracking()
|
|
||||||
.Where(z => z.Created < dtRunningDeadline && z.JobStatus == JobStatus.Running)
|
|
||||||
.OrderBy(z => z.Created)
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
log.LogTrace($"killStuckJobsAsync processing: cutoff={dtRunningDeadline.ToString()}, for {jobs.Count.ToString()} jobs of status {JobStatus.Running.ToString()}");
|
|
||||||
|
|
||||||
foreach (OpsJob j in jobs)
|
|
||||||
{
|
|
||||||
//OPSMETRIC
|
|
||||||
await JobsBiz.LogJobAsync(j.GId, "Job took too long to run - setting to failed", ct);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user