diff --git a/devdocs/todo.txt b/devdocs/todo.txt
index 5b45bb27..487b22fb 100644
--- a/devdocs/todo.txt
+++ b/devdocs/todo.txt
@@ -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
diff --git a/server/AyaNova/generator/CoreJobBackup.cs b/server/AyaNova/generator/CoreJobBackup.cs
index 5c804143..0f69b0ae 100644
--- a/server/AyaNova/generator/CoreJobBackup.cs
+++ b/server/AyaNova/generator/CoreJobBackup.cs
@@ -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
diff --git a/server/AyaNova/util/FileUtil.cs b/server/AyaNova/util/FileUtil.cs
index d1a31cba..6edfe0e5 100644
--- a/server/AyaNova/util/FileUtil.cs
+++ b/server/AyaNova/util/FileUtil.cs
@@ -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
}
}
+
+
+ ///
+ /// Cleanup excess backups (backup folder file)
+ ///
+ ///
+ 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