diff --git a/app/Services/Backups/InitiateBackupService.php b/app/Services/Backups/InitiateBackupService.php
index 3246328c9..aa53b88ae 100644
--- a/app/Services/Backups/InitiateBackupService.php
+++ b/app/Services/Backups/InitiateBackupService.php
@@ -116,16 +116,16 @@ class InitiateBackupService
}
// Check if the server has reached or exceeded it's backup limit
- if (! $server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
- if($override) {
- // Remove latest backup
- $last_backup = $server->backups()->where('is_successful', true)->oldest()->first();
- $this->deleteBackupService->handle($last_backup);
- } else {
- // Do not allow the user to continue if this server is already at its limit.
+ if (!$server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
+ // Do not allow the user to continue if this server is already at its limit and can't override.
+ if (!$override || $server->backup_limit <= 0) {
throw new TooManyBackupsException($server->backup_limit);
}
- }
+
+ // Remove latest backup
+ $lastBackup = $server->backups()->where('is_successful', true)->orderByDesc('created_at')->first();
+ $this->deleteBackupService->handle($lastBackup);
+ }
return $this->connection->transaction(function () use ($server, $name) {
/** @var \Pterodactyl\Models\Backup $backup */
diff --git a/resources/scripts/components/server/schedules/TaskDetailsModal.tsx b/resources/scripts/components/server/schedules/TaskDetailsModal.tsx
index 65c647219..08f33b161 100644
--- a/resources/scripts/components/server/schedules/TaskDetailsModal.tsx
+++ b/resources/scripts/components/server/schedules/TaskDetailsModal.tsx
@@ -91,7 +91,7 @@ const TaskDetailsForm = ({ isEditingTask }: { isEditingTask: boolean }) => {