Backup - essentially working

This commit is contained in:
2020-05-19 23:05:07 +00:00
parent fad10e4f26
commit 600ba796a0
3 changed files with 27 additions and 2 deletions

View File

@@ -13,7 +13,8 @@ todo: OPS routes (SERVER AND CLIENT)
- Backup, restore https://rockfish.ayanova.com/default.htm#!/rfcaseEdit/3369
- These need to be done fairly early on in order to have shit to play with for testing etc
todo: Test backup on Linux
- going to need to run in vm I think maybe
todo: Search indexing performance improvement and exception avoidance (Search.cs 828)
ON CONFLICT IDEA

View File

@@ -81,7 +81,7 @@ namespace AyaNova.Biz
log.LogInformation("BACKUP STUB: ATTACHMENTS BACKUP RUNNING NOW");
//PRUNE BACKUP SETS NOT KEPT
log.LogInformation("BACKUP STUB: PRUNING RUNNING NOW");
FileUtil.BackupCleanUp(ServerGlobalOpsSettings.BackupSetsToKeep);
//v.next - COPY TO ONLINE STORAGE

View File

@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using System.IO;
using System.IO.Compression;
@@ -152,6 +153,29 @@ namespace AyaNova.Util
}
}
/// <summary>
/// Cleanup excess backups (backup folder file)
/// </summary>
/// <param name="keepCount"></param>
internal static void BackupCleanUp(int keepCount)
{
if (keepCount < 1) keepCount = 1;
var BackupFileList = UtilityFileList("*.backup");
if (BackupFileList.Count > keepCount)
{
//sort, skip newest x (keepcount) delete the rest
var DeleteCount = BackupFileList.Count - keepCount;
var DeleteFileList = BackupFileList.OrderByDescending(m => m).Skip(keepCount).ToList();
foreach (string ExtraBackupFile in DeleteFileList)
{
DeleteUtilityFile(ExtraBackupFile);
}
}
}
#endregion Utility file handling
#region Zip handling