This commit is contained in:
2021-04-26 22:40:24 +00:00
parent dc86ec087d
commit c0f91d95a6
4 changed files with 18 additions and 22 deletions

View File

@@ -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));
}