Skip to content

Commit 7b8322e

Browse files
committed
Backup Rotation - Minor changes
1 parent 1eaf486 commit 7b8322e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

app/Services/Backups/InitiateBackupService.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,16 @@ public function handle(Server $server, string $name = null, bool $override = fal
116116
}
117117

118118
// Check if the server has reached or exceeded it's backup limit
119-
if (! $server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
120-
if($override) {
121-
// Remove latest backup
122-
$last_backup = $server->backups()->where('is_successful', true)->oldest()->first();
123-
$this->deleteBackupService->handle($last_backup);
124-
} else {
125-
// Do not allow the user to continue if this server is already at its limit.
119+
if (!$server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
120+
// Do not allow the user to continue if this server is already at its limit and can't override.
121+
if (!$override || $server->backup_limit <= 0) {
126122
throw new TooManyBackupsException($server->backup_limit);
127123
}
128-
}
124+
125+
// Remove latest backup
126+
$lastBackup = $server->backups()->where('is_successful', true)->orderByDesc('created_at')->first();
127+
$this->deleteBackupService->handle($lastBackup);
128+
}
129129

130130
return $this->connection->transaction(function () use ($server, $name) {
131131
/** @var \Pterodactyl\Models\Backup $backup */

resources/scripts/components/server/schedules/TaskDetailsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const TaskDetailsForm = ({ isEditingTask }: { isEditingTask: boolean }) => {
9191
<Label>Ignored Files</Label>
9292
<FormikFieldWrapper
9393
name={'payload'}
94-
description={'Optional. Include the files and folders to be excluded in this backup. By default, the contents of your .pteroignore file will be used.\nIf you have reached your backup limit, the oldest backup will be rotated.'}
94+
description={'Optional. Include the files and folders to be excluded in this backup. By default, the contents of your .pteroignore file will be used. If you have reached your backup limit, the oldest backup will be rotated.'}
9595
>
9696
<FormikField as={Textarea} name={'payload'} rows={6} />
9797
</FormikFieldWrapper>

0 commit comments

Comments
 (0)