DockerController: refactor StartBackupContainerBackup to show the stopping and starting state

Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
Simon L.
2026-03-06 10:40:45 +01:00
parent 510032d7a1
commit 6e87758ba9
2 changed files with 13 additions and 6 deletions

View File

@@ -87,19 +87,26 @@ readonly class DockerController {
}
public function StartBackupContainerBackup(Request $request, Response $response, array $args) : Response {
// Get streaming response start and closure
$nonbufResp = $this->startStreamingResponse($response);
$addToStreamingResponseBody = $this->getAddToStreamingResponseBody($nonbufResp);
$forceStopNextcloud = true;
$this->startBackup($forceStopNextcloud);
return $response->withStatus(201)->withHeader('Location', '.');
$this->startBackup($forceStopNextcloud, $addToStreamingResponseBody);
// End streaming response
$this->finalizeStreamingResponse($nonbufResp);
return $nonbufResp;
}
public function startBackup(bool $forceStopNextcloud = false) : void {
public function startBackup(bool $forceStopNextcloud = false, ?\Closure $addToStreamingResponseBody = null) : void {
$this->configurationManager->backupMode = 'backup';
$id = self::TOP_CONTAINER;
$this->PerformRecursiveContainerStop($id, $forceStopNextcloud);
$this->PerformRecursiveContainerStop($id, $forceStopNextcloud, $addToStreamingResponseBody);
$id = 'nextcloud-aio-borgbackup';
$this->PerformRecursiveContainerStart($id);
$this->PerformRecursiveContainerStart($id, true, $addToStreamingResponseBody);
}
public function StartBackupContainerCheck(Request $request, Response $response, array $args) : Response {

View File

@@ -472,7 +472,7 @@
{% if isApacheStarting != true %}
<h3>Backup creation</h3>
<p>Clicking on the button below will create a backup.</p>
<form method="POST" action="api/docker/backup" class="xhr">
<form method="POST" action="api/docker/backup" target="overlay-log">
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
<input type="submit" value="Create backup" onclick="return confirm('Create backup? Are you sure that you want to create a backup? This will stop all running containers and create the backup.')" />