From cd8abbf7b42e19b3c5d543c2a1f664300ff5fb20 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Tue, 10 Nov 2026 11:00:05 +0100 Subject: [PATCH] fix(cleanup): delete failed database backup records after the retention days Backup retention removes only successful runs, so failed runs stayed in scheduled_database_backup_executions forever. A failed run has no local file and no S3 copy, so the daily database cleanup can delete its record. Co-Authored-By: Claude Opus 5.5 --- .changes/kept-the-records-of-failed-database.md | 6 ++++++ app/Console/Commands/CleanupDatabase.php | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 .changes/kept-the-records-of-failed-database.md diff --git a/.changes/kept-the-records-of-failed-database.md b/.changes/kept-the-records-of-failed-database.md new file mode 100644 index 0000000000..a3aefab4c9 --- /dev/null +++ b/.changes/kept-the-records-of-failed-database.md @@ -0,0 +1,6 @@ +--- +type: fixed +--- +Kept the records of failed database backups forever + +- The daily database cleanup deletes failed database backups that are older than 60 days diff --git a/app/Console/Commands/CleanupDatabase.php b/app/Console/Commands/CleanupDatabase.php index e3bdee090f..ffb4c7df06 100644 --- a/app/Console/Commands/CleanupDatabase.php +++ b/app/Console/Commands/CleanupDatabase.php @@ -48,6 +48,10 @@ class CleanupDatabase extends Command $this->cleanupTable('scheduled_task_executions', 'created_at', now()->subDays($keep_days)); + // Backup retention removes only successful runs. A failed run has no file, so only its record is left. + $this->cleanupTable('scheduled_database_backup_executions', 'created_at', now()->subDays($keep_days), fn (Builder $query) => $query + ->where('status', 'failed')); + $this->cleanupTable('github_runner_executions', 'created_at', now()->subDays($keep_days), fn (Builder $query) => $query ->whereNotIn('status', array_map(fn (GithubRunnerStatus $status): string => $status->value, GithubRunnerStatus::active()))); }