From c0f91d95a6fa1af992cc50907a8c85704575e204 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 26 Apr 2021 22:40:24 +0000 Subject: [PATCH] --- Controllers/OpsController.cs | 5 ----- notes/deploy.txt | 2 +- util/OpsDiagnostics.cs | 31 ++++++++++++++++--------------- util/RfVersion.cs | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Controllers/OpsController.cs b/Controllers/OpsController.cs index 4335c05..2185b86 100644 --- a/Controllers/OpsController.cs +++ b/Controllers/OpsController.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Authorization; -using Microsoft.EntityFrameworkCore; using rockfishCore.Models; using rockfishCore.Util; diff --git a/notes/deploy.txt b/notes/deploy.txt index 77f5ad0..3c7cd9d 100644 --- a/notes/deploy.txt +++ b/notes/deploy.txt @@ -23,7 +23,7 @@ dotnet publish -o ./../publish/ 3) COPY Copy over to production server, -.NET Core apps: /var/aspnetcore +.NET Core apps: /srv/coreapps only need the .dll and the wwwroot folder contents, remember not to delete the folders on the server only replace their contents because there are file permissions set Backup the database diff --git a/util/OpsDiagnostics.cs b/util/OpsDiagnostics.cs index 677f475..d51945a 100644 --- a/util/OpsDiagnostics.cs +++ b/util/OpsDiagnostics.cs @@ -12,10 +12,6 @@ namespace rockfishCore.Util { public static class OpsDiagnostics { - private const int S3_EXPECTED_FILE_COUNT = 24; - public static readonly string[] S3_EXPECTED_BACKUP_FILE_PREFIXES = - { "biz-docker-website-backup-", "biz-letsencryptbackup-", "biz-pecklist-db-backup-", "biz-rockfish-db-backup-", - "devops-docker-le-config-backup-","forum-backup-", "mail-svn-repo-backup-" }; private const string S3_SECRET_KEY = "iNwbHr+sK+9is2wmRjIax+rdyEjLNvWKJBYr7w4txkY"; private const string S3_ACCESS_KEY = "CMPAFDNX53OWPC55HBJ4"; private const string S3_HOST_ENDPOINT = "https://nyc3.digitaloceanspaces.com"; @@ -103,31 +99,36 @@ namespace rockfishCore.Util public static bool VerifyBackups() { - bool ret = false; + string[] CriticalDailyBackupFilePrefixes = { "ayanova21-pecklist-db-backup-", "ayanova21-rockfish-db-backup-", "mail21-svn-backup-" }; + string[] Level2ManualBackupFilePrefixes = { "forum21-backup-", "ayanova21-website-backup-" }; var SpacesFileNames = GetFileListFromSpacesBackupStorage(); - if (SpacesFileNames.Count != S3_EXPECTED_FILE_COUNT) return ret; + + //Daily critical files //get yesterday's date in the same format as the backup creates var ExpectedBackupDateString = DateTime.Today.AddDays(-1).ToString("yyMMdd"); - int foundMatches = 0; - foreach (string ExpectedFileName in S3_EXPECTED_BACKUP_FILE_PREFIXES) + int FoundCriticalMatches = 0; + foreach (string ExpectedFileName in CriticalDailyBackupFilePrefixes) { foreach (string FileName in SpacesFileNames) { if (FileName.StartsWith(ExpectedFileName + ExpectedBackupDateString)) { - foundMatches++; + FoundCriticalMatches++; break; } } } - if (foundMatches == S3_EXPECTED_BACKUP_FILE_PREFIXES.Length) - { - ret = true; - } - - return ret; + //Website and Forum sb at least three of each, so just ensure there are three matches + //we dont' care about date for these ones, just prescence + int FoundLevel2Matches = 0; + foreach (string ExpectedFileName in Level2ManualBackupFilePrefixes) + foreach (string FileName in SpacesFileNames) + if (FileName.StartsWith(ExpectedFileName)) + FoundLevel2Matches++; + //should be one each of the critical and 3 each of the level2 + return (FoundCriticalMatches == CriticalDailyBackupFilePrefixes.Length && FoundLevel2Matches == (Level2ManualBackupFilePrefixes.Length * 3)); } diff --git a/util/RfVersion.cs b/util/RfVersion.cs index 4ed5d97..69a6d9c 100644 --- a/util/RfVersion.cs +++ b/util/RfVersion.cs @@ -2,7 +2,7 @@ namespace rockfishCore.Util { public static class RfVersion { - public const string NumberOnly="6.10"; + public const string NumberOnly="6.11"; public const string Full = "Rockfish server " + NumberOnly; } } \ No newline at end of file