fix: backup job deletion - delete all backups from s3 and local
This commit is contained in:
parent
c03b629e85
commit
3dfca4e4bd
2 changed files with 30 additions and 10 deletions
|
|
@ -123,13 +123,29 @@ public function delete($password)
|
|||
}
|
||||
|
||||
try {
|
||||
if ($this->delete_associated_backups_locally) {
|
||||
$filenames = $this->backup->executions->pluck('filename')->filter()->all();
|
||||
deleteBackupsLocally($filenames, $this->backup->server);
|
||||
$server = null;
|
||||
if ($this->backup->database instanceof \App\Models\ServiceDatabase) {
|
||||
$server = $this->backup->database->service->destination->server;
|
||||
} elseif ($this->backup->database->destination && $this->backup->database->destination->server) {
|
||||
$server = $this->backup->database->destination->server;
|
||||
}
|
||||
if ($this->delete_associated_backups_s3 && $this->backup->s3) {
|
||||
$filenames = $this->backup->executions->pluck('filename')->filter()->all();
|
||||
deleteBackupsS3($filenames, $this->backup->s3);
|
||||
|
||||
$filenames = $this->backup->executions()
|
||||
->whereNotNull('filename')
|
||||
->where('filename', '!=', '')
|
||||
->where('scheduled_database_backup_id', $this->backup->id)
|
||||
->pluck('filename')
|
||||
->filter()
|
||||
->all();
|
||||
|
||||
if (! empty($filenames)) {
|
||||
if ($this->delete_associated_backups_locally && $server) {
|
||||
deleteBackupsLocally($filenames, $server);
|
||||
}
|
||||
|
||||
if ($this->delete_associated_backups_s3 && $this->backup->s3) {
|
||||
deleteBackupsS3($filenames, $this->backup->s3);
|
||||
}
|
||||
}
|
||||
|
||||
$this->backup->delete();
|
||||
|
|
@ -145,7 +161,9 @@ public function delete($password)
|
|||
} else {
|
||||
return redirect()->route('project.database.backup.index', $this->parameters);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
} catch (\Exception $e) {
|
||||
$this->dispatch('error', 'Failed to delete backup: '.$e->getMessage());
|
||||
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,10 +62,12 @@ public function deleteBackup($executionId, $password)
|
|||
: $execution->scheduledDatabaseBackup->database->destination->server;
|
||||
|
||||
try {
|
||||
deleteBackupsLocally($execution->filename, $server);
|
||||
if ($execution->filename) {
|
||||
deleteBackupsLocally($execution->filename, $server);
|
||||
|
||||
if ($this->delete_backup_s3 && $execution->scheduledDatabaseBackup->s3) {
|
||||
deleteBackupsS3($execution->filename, $execution->scheduledDatabaseBackup->s3);
|
||||
if ($this->delete_backup_s3 && $execution->scheduledDatabaseBackup->s3) {
|
||||
deleteBackupsS3($execution->filename, $execution->scheduledDatabaseBackup->s3);
|
||||
}
|
||||
}
|
||||
|
||||
$execution->delete();
|
||||
|
|
|
|||
Loading…
Reference in a new issue