This commit is contained in:
@@ -30,7 +30,3 @@ Mailkit (supposedly system.net.mail will be ported in v2.0 of .net core but for
|
|||||||
<!--PackageReference Include="bouncycastle.netcore" Version="1.8.1.3" /-->
|
<!--PackageReference Include="bouncycastle.netcore" Version="1.8.1.3" /-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uidnext {61644} {685} {61644} {685}
|
|
||||||
uidvalidity 1276936849 1532556097 1276936849 1532556097
|
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AWSSDK.Core" Version="3.3.24.4" />
|
|
||||||
<PackageReference Include="AWSSDK.S3" Version="3.3.20" />
|
<PackageReference Include="AWSSDK.S3" Version="3.3.20" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />
|
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
|
||||||
|
|||||||
@@ -1,24 +1,21 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.IO;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using Amazon.S3;
|
using Amazon.S3;
|
||||||
using Amazon.S3.Transfer;
|
|
||||||
|
|
||||||
namespace rockfishCore.Util
|
namespace rockfishCore.Util
|
||||||
{
|
{
|
||||||
public static class OpsDiagnostics
|
public static class OpsDiagnostics
|
||||||
{
|
{
|
||||||
private const int S3_EXPECTED_FILE_COUNT=24;
|
private const int S3_EXPECTED_FILE_COUNT = 24;
|
||||||
public static readonly string[] S3_EXPECTED_BACKUP_FILE_PREFIXES =
|
public static readonly string[] S3_EXPECTED_BACKUP_FILE_PREFIXES =
|
||||||
{ "biz-docker-website-backup-", "biz-letsencryptbackup-", "biz-pecklist-db-backup-", "biz-rockfish-db-backup-",
|
{ "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-" };
|
"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_SECRET_KEY = "iNwbHr+sK+9is2wmRjIax+rdyEjLNvWKJBYr7w4txkY";
|
||||||
private const string S3_ACCESS_KEY = "CMPAFDNX53OWPC55HBJ4";
|
private const string S3_ACCESS_KEY = "CMPAFDNX53OWPC55HBJ4";
|
||||||
private const string S3_HOST_ENDPOINT = "https://nyc3.digitaloceanspaces.com";
|
private const string S3_HOST_ENDPOINT = "https://nyc3.digitaloceanspaces.com";
|
||||||
|
private const string S3_BUCKET_NAME = "gztw1";
|
||||||
|
|
||||||
private static HttpClient Client = new HttpClient();
|
private static HttpClient Client = new HttpClient();
|
||||||
|
|
||||||
@@ -41,34 +38,37 @@ namespace rockfishCore.Util
|
|||||||
|
|
||||||
public static List<string> GetFileListFromSpacesBackupStorage()
|
public static List<string> GetFileListFromSpacesBackupStorage()
|
||||||
{
|
{
|
||||||
|
AmazonS3Config ClientConfig = new AmazonS3Config();
|
||||||
AmazonS3Config clientConfig = new AmazonS3Config();
|
ClientConfig.ServiceURL = S3_HOST_ENDPOINT;
|
||||||
clientConfig.ServiceURL = S3_HOST_ENDPOINT;
|
IAmazonS3 s3Client = new AmazonS3Client(S3_ACCESS_KEY, S3_SECRET_KEY, ClientConfig);
|
||||||
IAmazonS3 s3Client = new AmazonS3Client(S3_ACCESS_KEY, S3_SECRET_KEY, clientConfig);
|
var ObjectList = s3Client.ListObjectsAsync(S3_BUCKET_NAME).Result;
|
||||||
var objectList = s3Client.ListObjectsAsync("gztw1").Result;
|
var FileList = ObjectList.S3Objects.Select(c => c.Key).ToList();
|
||||||
var fileList = objectList.S3Objects.Select(c => c.Key).ToList();
|
return FileList;
|
||||||
return fileList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool VerifyBackups()
|
public static bool VerifyBackups()
|
||||||
{
|
{
|
||||||
bool ret=false;
|
bool ret = false;
|
||||||
var SpacesFileNames = GetFileListFromSpacesBackupStorage();
|
var SpacesFileNames = GetFileListFromSpacesBackupStorage();
|
||||||
if (SpacesFileNames.Count != S3_EXPECTED_FILE_COUNT) return ret;
|
if (SpacesFileNames.Count != S3_EXPECTED_FILE_COUNT) return ret;
|
||||||
//get yesterday's date in the same format as the backup creates
|
//get yesterday's date in the same format as the backup creates
|
||||||
var ExpectedBackupDateString=DateTime.Today.AddDays(-1).ToString("yyMMdd");
|
var ExpectedBackupDateString = DateTime.Today.AddDays(-1).ToString("yyMMdd");
|
||||||
int foundMatches=0;
|
int foundMatches = 0;
|
||||||
foreach(string ExpectedFileName in S3_EXPECTED_BACKUP_FILE_PREFIXES){
|
foreach (string ExpectedFileName in S3_EXPECTED_BACKUP_FILE_PREFIXES)
|
||||||
foreach(string FileName in SpacesFileNames){
|
{
|
||||||
if(FileName.StartsWith(ExpectedFileName+ExpectedBackupDateString)){
|
foreach (string FileName in SpacesFileNames)
|
||||||
|
{
|
||||||
|
if (FileName.StartsWith(ExpectedFileName + ExpectedBackupDateString))
|
||||||
|
{
|
||||||
foundMatches++;
|
foundMatches++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(foundMatches==S3_EXPECTED_BACKUP_FILE_PREFIXES.Length){
|
if (foundMatches == S3_EXPECTED_BACKUP_FILE_PREFIXES.Length)
|
||||||
ret=true;
|
{
|
||||||
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user