Consolidate backup entry points and retention into shared helpers #230
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
"All backup functions should be in a shared helper if they aren't." Audit found duplicated logic across the codebase:
Retention (two implementations, both local-only)
Engine/RetentionManager::prune()— runs after each backup.plg_system_mokosuitebackupdoCleanup()/deleteBackupRecord()— hourly admin-side sweep, re-implementing the same age+count prune plus its own file-delete copy. It also applied the globalmax_age_days/max_backupsfallback thatRetentionManagerdid not.Uploader factory (three copies)
createUploaderFromParams()duplicated verbatim inBackupEngineandSteppedBackupEngine, and needed a third time by retention for remote deletion.Backup entry points (three bypassing the shared service)
BackupRunneris the shared synchronous entry point, but the backendBackupsController, the APIBackupsController, and the legacycli/mokosuitebackup.phpeach instantiatedBackupEnginedirectly — losing the normalized complete/warning/fail status.Changes (in progress)
Engine/RemoteUploaderFactory::create()— single home for the type→class map + key-prefixing; both engines now delegate to it.RetentionManageris now the single retention authority: accepts global-default fallback, addspruneOrphans(), and deletes from remotes. The plugin'sdoCleanup()delegates to it and its duplicatedeleteBackupRecord()is removed.BackupRunner.(The dashboard AJAX
SteppedBackupEngineinteractive path is intentionally left separate.)https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i
Branch created:
feature/230-consolidate-backup-entry-points-and-reteDone in #231, merged to
dev.RemoteUploaderFactorynow owns the type→class map (both engines delegate);RetentionManageris the single retention authority (global-default fallback +pruneOrphans()) with the plugin delegating to it; backend/API/legacy-CLI backup triggers route throughBackupRunner. DashboardSteppedBackupEngineinteractive path left separate by design.