feat: new global s3 and local backup deletion function

This commit is contained in:
peaklabs-dev
2025-01-13 16:37:36 +01:00
parent e037ed738a
commit fb01aed6d5
2 changed files with 245 additions and 11 deletions

View File

@@ -459,14 +459,9 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue
private function remove_old_backups(): void
{
if ($this->backup->number_of_backups_locally === 0) {
$deletable = $this->backup->executions()->where('status', 'success');
} else {
$deletable = $this->backup->executions()->where('status', 'success')->skip($this->backup->number_of_backups_locally - 1);
}
foreach ($deletable->get() as $execution) {
delete_backup_locally($execution->filename, $this->server);
$execution->delete();
deleteOldBackupsLocally($this->backup);
if ($this->backup->save_s3) {
deleteOldBackupsFromS3($this->backup);
}
}