PR: Sub Issue 9 - BackupConfig + Restore/CleanBackup#328
Merged
Conversation
- StorageManager.Restore() — restore from backup to install path - StorageManager.CleanBackup() — keep only N most recent backups - StorageManager.ListBackups() — query backup metadata - BackupConfig — version retention, skip dirs, enable/disable - BackupInfo record — version, path, timestamp, size Closes #327
Contributor
There was a problem hiding this comment.
Pull request overview
Adds backup management capabilities to GeneralUpdate.Core by introducing backup metadata/config types and new StorageManager APIs for restoring from backups, listing backup versions, and cleaning up old backups (Sub Issue 9, closes #327).
Changes:
- Added
StorageManager.Restore()(bulk restore),CleanBackup()(keep N newest), andListBackups()(metadata + size). - Introduced
BackupConfig(Enabled/KeepVersions/BackupRoot/SkipDirectories). - Introduced
BackupInforecord (Version/Path/CreatedAt/SizeBytes).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+286
to
+288
| /// <summary>Restore files from backup directory to install path.</summary> | ||
| public static void Restore(string backupDir, string installPath) | ||
| { |
Comment on lines
+301
to
+314
| /// <summary>Clean old backups, keeping only the N most recent versions.</summary> | ||
| public static void CleanBackup(string installPath, int keepVersions = 3) | ||
| { | ||
| var backupRoot = Path.Combine(installPath, "__backups"); | ||
| if (!Directory.Exists(backupRoot)) return; | ||
|
|
||
| var dirs = Directory.GetDirectories(backupRoot) | ||
| .Select(d => new DirectoryInfo(d)) | ||
| .OrderByDescending(d => d.CreationTime) | ||
| .Skip(keepVersions); | ||
|
|
||
| foreach (var dir in dirs) | ||
| dir.Delete(true); | ||
| } |
Comment on lines
+316
to
+328
| /// <summary>List backup versions with metadata.</summary> | ||
| public static IReadOnlyList<BackupInfo> ListBackups(string installPath) | ||
| { | ||
| var backupRoot = Path.Combine(installPath, "__backups"); | ||
| if (!Directory.Exists(backupRoot)) return Array.Empty<BackupInfo>(); | ||
|
|
||
| return Directory.GetDirectories(backupRoot) | ||
| .Select(d => new DirectoryInfo(d)) | ||
| .Select(d => new BackupInfo( | ||
| d.Name, d.FullName, d.CreationTime, | ||
| d.GetFiles("*", SearchOption.AllDirectories).Sum(f => f.Length))) | ||
| .ToList(); | ||
| } |
Comment on lines
+286
to
+287
| /// <summary>Restore files from backup directory to install path.</summary> | ||
| public static void Restore(string backupDir, string installPath) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #327
Changes
Build
✅ 0 errors