Skip to content

Commit 1eaf486

Browse files
committed
Backup Rotation - Minor Changes
1 parent 1f01c65 commit 1eaf486

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

app/Services/Backups/InitiateBackupService.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function setIgnoredFiles(?array $ignored)
105105
* @throws \Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException
106106
* @throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException
107107
*/
108-
public function handle(Server $server, string $name = null, bool $override = null): Backup
108+
public function handle(Server $server, string $name = null, bool $override = false): Backup
109109
{
110110
$previous = $this->repository->getBackupsGeneratedDuringTimespan($server->id, 10);
111111
if ($previous->count() >= 2) {
@@ -115,12 +115,13 @@ public function handle(Server $server, string $name = null, bool $override = nul
115115
);
116116
}
117117

118+
// Check if the server has reached or exceeded it's backup limit
118119
if (! $server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
119-
if($override){
120+
if($override) {
120121
// Remove latest backup
121122
$last_backup = $server->backups()->where('is_successful', true)->oldest()->first();
122123
$this->deleteBackupService->handle($last_backup);
123-
}else{
124+
} else {
124125
// Do not allow the user to continue if this server is already at its limit.
125126
throw new TooManyBackupsException($server->backup_limit);
126127
}
@@ -136,7 +137,9 @@ public function handle(Server $server, string $name = null, bool $override = nul
136137
'disk' => $this->backupManager->getDefaultAdapter(),
137138
], true, true);
138139

139-
$this->daemonBackupRepository->setServer($server)->setBackupAdapter($this->backupManager->getDefaultAdapter())->backup($backup);
140+
$this->daemonBackupRepository->setServer($server)
141+
->setBackupAdapter($this->backupManager->getDefaultAdapter())
142+
->backup($backup);
140143

141144
return $backup;
142145
});

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 dont have more backups spaces it will OVERRIDE the oldest.'}
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.'}
9595
>
9696
<FormikField as={Textarea} name={'payload'} rows={6} />
9797
</FormikFieldWrapper>

0 commit comments

Comments
 (0)