fix: use new removeOldBackups function
- use the new removeOldBackups function - only call removeOldBackups function when the backup is completed and also only if the backup is successful
This commit is contained in:
parent
3dfca4e4bd
commit
9eebeb9241
1 changed files with 3 additions and 9 deletions
|
|
@ -299,7 +299,6 @@ public function handle(): void
|
|||
throw new \Exception('Unsupported database type');
|
||||
}
|
||||
$size = $this->calculate_size();
|
||||
$this->remove_old_backups();
|
||||
if ($this->backup->save_s3) {
|
||||
$this->upload_to_s3();
|
||||
}
|
||||
|
|
@ -323,6 +322,9 @@ public function handle(): void
|
|||
$this->team?->notify(new BackupFailed($this->backup, $this->database, $this->backup_output, $database));
|
||||
}
|
||||
}
|
||||
if ($this->backup_log && $this->backup_log->status === 'success') {
|
||||
removeOldBackups($this->backup);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
throw $e;
|
||||
} finally {
|
||||
|
|
@ -457,14 +459,6 @@ private function calculate_size()
|
|||
return instant_remote_process(["du -b $this->backup_location | cut -f1"], $this->server, false);
|
||||
}
|
||||
|
||||
private function remove_old_backups(): void
|
||||
{
|
||||
deleteOldBackupsLocally($this->backup);
|
||||
if ($this->backup->save_s3) {
|
||||
deleteOldBackupsFromS3($this->backup);
|
||||
}
|
||||
}
|
||||
|
||||
private function upload_to_s3(): void
|
||||
{
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue