is_locked && ($backup->is_successful && ($backup->completed_at) !== null), BackupLockedException::class); if ($backup->disk === Backup::ADAPTER_AWS_S3) { $this->deleteFromS3($backup); return; } DB::transaction(function () use ($backup): void { try { Daemon::server($backup->server)->backups()->delete($backup); } catch (DaemonConnectionException $daemonConnectionException) { // Don't fail the request if the Daemon responds with a 404, just assume the backup // doesn't actually exist and remove its reference from the Panel as well. throw_if($daemonConnectionException->getStatusCode() !== Response::HTTP_NOT_FOUND, $daemonConnectionException); } $backup->delete(); }); } /** * Deletes a backup from an S3 disk. * * @throws Throwable */ private function deleteFromS3(Backup $backup): void { DB::transaction(function () use ($backup): void { $backup->delete(); $adapter = $this->manager->adapter(Backup::ADAPTER_AWS_S3); throw_unless($adapter instanceof S3Filesystem, LogicException::class, 'The S3 backup adapter is not configured correctly.'); $adapter->getClient()->deleteObject([ 'Bucket' => $adapter->getBucket(), 'Key' => sprintf('%s/%s.tar.gz', $backup->server->uuid, $backup->uuid), ]); }); } }