Backup Rotation - Minor Changes
This commit is contained in:
parent
1f01c653f1
commit
1eaf486eaa
2 changed files with 8 additions and 5 deletions
|
@ -105,7 +105,7 @@ class InitiateBackupService
|
||||||
* @throws \Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException
|
* @throws \Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException
|
||||||
* @throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException
|
* @throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException
|
||||||
*/
|
*/
|
||||||
public function handle(Server $server, string $name = null, bool $override = null): Backup
|
public function handle(Server $server, string $name = null, bool $override = false): Backup
|
||||||
{
|
{
|
||||||
$previous = $this->repository->getBackupsGeneratedDuringTimespan($server->id, 10);
|
$previous = $this->repository->getBackupsGeneratedDuringTimespan($server->id, 10);
|
||||||
if ($previous->count() >= 2) {
|
if ($previous->count() >= 2) {
|
||||||
|
@ -115,12 +115,13 @@ 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 (! $server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
|
||||||
if($override){
|
if($override) {
|
||||||
// Remove latest backup
|
// Remove latest backup
|
||||||
$last_backup = $server->backups()->where('is_successful', true)->oldest()->first();
|
$last_backup = $server->backups()->where('is_successful', true)->oldest()->first();
|
||||||
$this->deleteBackupService->handle($last_backup);
|
$this->deleteBackupService->handle($last_backup);
|
||||||
}else{
|
} else {
|
||||||
// Do not allow the user to continue if this server is already at its limit.
|
// Do not allow the user to continue if this server is already at its limit.
|
||||||
throw new TooManyBackupsException($server->backup_limit);
|
throw new TooManyBackupsException($server->backup_limit);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +137,9 @@ class InitiateBackupService
|
||||||
'disk' => $this->backupManager->getDefaultAdapter(),
|
'disk' => $this->backupManager->getDefaultAdapter(),
|
||||||
], true, true);
|
], true, true);
|
||||||
|
|
||||||
$this->daemonBackupRepository->setServer($server)->setBackupAdapter($this->backupManager->getDefaultAdapter())->backup($backup);
|
$this->daemonBackupRepository->setServer($server)
|
||||||
|
->setBackupAdapter($this->backupManager->getDefaultAdapter())
|
||||||
|
->backup($backup);
|
||||||
|
|
||||||
return $backup;
|
return $backup;
|
||||||
});
|
});
|
||||||
|
|
|
@ -91,7 +91,7 @@ const TaskDetailsForm = ({ isEditingTask }: { isEditingTask: boolean }) => {
|
||||||
<Label>Ignored Files</Label>
|
<Label>Ignored Files</Label>
|
||||||
<FormikFieldWrapper
|
<FormikFieldWrapper
|
||||||
name={'payload'}
|
name={'payload'}
|
||||||
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.'}
|
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.'}
|
||||||
>
|
>
|
||||||
<FormikField as={Textarea} name={'payload'} rows={6} />
|
<FormikField as={Textarea} name={'payload'} rows={6} />
|
||||||
</FormikFieldWrapper>
|
</FormikFieldWrapper>
|
||||||
|
|
Loading…
Reference in a new issue