Skip to content

Conversation

@BornToBeRoot
Copy link
Owner

@BornToBeRoot BornToBeRoot commented Dec 25, 2025

Changes proposed in this pull request

  • Create a daily backup
  • Cleanup backups older than 10 files

Related issue(s)

Copilot generated summary

Provide a Copilot generated summary of the changes in this pull request.

Copilot summary

This pull request introduces a daily backup system for the application's settings file, ensuring that a backup is created only once per day and that old backups are cleaned up according to a configurable retention limit. It also adds tracking of the last backup date and improves backup management during settings migration and saving.

Backup and retention improvements:

  • Added a CreateDailyBackupIfNeeded method in SettingsManager.cs to create a backup of the settings file only if one hasn't been created for the current day, and to clean up old backups based on a configurable maximum.
  • Introduced a CleanupBackups method to retain only the most recent backups up to the configured maximum, deleting older ones to manage disk usage.
  • Added a Backup method to encapsulate the logic for copying the settings file to the backup location, used during both migration and daily backup routines. [1] [2]
  • Added Backup_MaximumNumberOfBackups constant to GlobalStaticConfiguration.cs to configure the maximum number of retained backups.

Settings tracking and migration:

  • Added a LastBackup property to SettingsInfo.cs to track the date of the last performed backup, ensuring daily backups are not duplicated.
  • Updated the settings migration logic to use the new Backup method for legacy file backup, streamlining and unifying backup operations.
  • Modified the Save method in SettingsManager.cs to call CreateDailyBackupIfNeeded before saving, ensuring backups are consistently created as needed.

Other code improvements:

  • Used collection initializer syntax ([]) for the _pingMonitor_HostHistory field in SettingsInfo.cs for conciseness.

To-Do

Contributing

By submitting this pull request, I confirm the following:

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a daily backup system for application settings. The implementation creates automatic backups once per day, tracks the last backup date, and maintains a maximum of 10 backup files by cleaning up older ones.

Key changes:

  • Added automatic daily backup creation with date tracking to prevent duplicate backups on the same day
  • Implemented backup retention policy that keeps only the 10 most recent backup files
  • Refactored backup logic into reusable methods that handle both daily backups and legacy file migration

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 7 comments.

File Description
Source/NETworkManager.Settings/SettingsManager.cs Implements daily backup creation, cleanup logic, and refactored backup method; integrates backup creation into the settings save workflow
Source/NETworkManager.Settings/SettingsInfo.cs Adds LastBackup property to track backup dates and updates collection initializer syntax
Source/NETworkManager.Settings/GlobalStaticConfiguration.cs Defines maximum backup file retention limit (10 backups)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Dec 25, 2025

@BornToBeRoot I've opened a new pull request, #3284, to work on those changes. Once the pull request is ready, I'll request review from you.

@BornToBeRoot BornToBeRoot changed the title Feature: Daily settings backuo Feature: Daily settings backup Dec 25, 2025
Copilot AI and others added 2 commits December 25, 2025 23:21
* Initial plan

* Extract date from filename for backup ordering

Co-authored-by: BornToBeRoot <[email protected]>

* Use InvariantCulture and specific exception handling

Co-authored-by: BornToBeRoot <[email protected]>

* Move ExtractTimestampFromFilename to TimestampHelper in Utilities

Co-authored-by: BornToBeRoot <[email protected]>

* Update comment to match specific exception handling

Co-authored-by: BornToBeRoot <[email protected]>

* Feature: Improve check

* Update Source/NETworkManager.Utilities/TimestampHelper.cs

Co-authored-by: Copilot <[email protected]>

* Update Source/NETworkManager.Utilities/TimestampHelper.cs

Co-authored-by: Copilot <[email protected]>

* Update Source/NETworkManager.Utilities/TimestampHelper.cs

Co-authored-by: Copilot <[email protected]>

* Update TimestampHelper.cs

* Update TimestampHelper.cs

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: BornToBeRoot <[email protected]>
Co-authored-by: Copilot <[email protected]>
@mergify mergify bot merged commit f550c81 into main Dec 25, 2025
4 checks passed
@mergify mergify bot deleted the feature/daily_settings_backup branch December 25, 2025 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants