From 911d85c230993a8717cd87007a8b13a2378b6e0c Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Mon, 7 Dec 2020 09:31:44 -0700 Subject: [PATCH] Delete the oldest backup, not the newest backup, closes #2800 --- app/Services/Backups/InitiateBackupService.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Services/Backups/InitiateBackupService.php b/app/Services/Backups/InitiateBackupService.php index 210e92342..0857478ba 100644 --- a/app/Services/Backups/InitiateBackupService.php +++ b/app/Services/Backups/InitiateBackupService.php @@ -13,7 +13,6 @@ use Pterodactyl\Repositories\Eloquent\BackupRepository; use Pterodactyl\Repositories\Wings\DaemonBackupRepository; use Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; -use Pterodactyl\Services\Backups\DeleteBackupService; class InitiateBackupService { @@ -124,8 +123,11 @@ class InitiateBackupService throw new TooManyBackupsException($server->backup_limit); } - // Remove oldest backup - $oldestBackup = $server->backups()->where('is_successful', true)->orderByDesc('created_at')->first(); + // Get the oldest backup the server has. + /** @var \Pterodactyl\Models\Backup $oldestBackup */ + $oldestBackup = $server->backups()->where('is_successful', true)->orderBy('created_at')->first(); + + // Delete the oldest backup. $this->deleteBackupService->handle($oldestBackup); }