status) !== null, BadRequestHttpException::class, 'This server is not currently in a state that allows for a backup to be restored.'); throw_if(! $backup->is_successful || ($backup->completed_at) === null, BadRequestHttpException::class, 'This backup cannot be restored at this time: not completed or failed.'); DB::transaction(function () use ($server, $backup, $user, $truncate): void { $url = $backup->disk === Backup::ADAPTER_AWS_S3 ? $this->downloadLink->generate($backup, $user) : null; $server->update(['status' => Server::STATUS_RESTORING_BACKUP]); Daemon::server($server)->backups()->restore($backup, $url, $truncate); }); } }