aio-interface: also reset the borg backup cache when resetting the backup path

Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-25 12:50:27 +00:00
committed by Simon L.
parent 39f30a6609
commit 172c72f735
5 changed files with 29 additions and 9 deletions

View File

@@ -103,6 +103,7 @@ $app->post('/api/docker/backup-check-repair', AIO\Controller\DockerController::c
$app->post('/api/docker/backup-test', AIO\Controller\DockerController::class . ':StartBackupContainerTest');
$app->post('/api/docker/restore', AIO\Controller\DockerController::class . ':StartBackupContainerRestore');
$app->post('/api/docker/stop', AIO\Controller\DockerController::class . ':StopContainer');
$app->post('/api/docker/backup-reset-location', AIO\Controller\DockerController::class . ':DeleteBorgBackupConfig');
$app->post('/api/docker/prune', AIO\Controller\DockerController::class . ':SystemPrune');
$app->get('/api/docker/logs', AIO\Controller\DockerController::class . ':GetLogs');
$app->post('/api/auth/login', AIO\Controller\LoginController::class . ':TryLogin');

View File

@@ -3,16 +3,14 @@ declare(strict_types=1);
namespace AIO\Controller;
use AIO\ContainerDefinitionFetcher;
use AIO\Data\ConfigurationManager;
use AIO\Data\InvalidSettingConfigurationException;
use AIO\Docker\DockerActionManager;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
readonly class ConfigurationController {
public function __construct(
private ConfigurationManager $configurationManager
private ConfigurationManager $configurationManager,
) {
}
@@ -132,10 +130,6 @@ readonly class ConfigurationController {
$this->configurationManager->collaboraAdditionalOptions = $additionalCollaboraOptions;
}
if (isset($request->getParsedBody()['delete_borg_backup_location_vars'])) {
$this->configurationManager->deleteBorgBackupLocationItems();
}
return $response->withStatus(201)->withHeader('Location', '.');
} catch (InvalidSettingConfigurationException $ex) {
$response->getBody()->write($ex->getMessage());

View File

@@ -328,6 +328,11 @@ readonly class DockerController {
return $nonbufResp;
}
public function DeleteBorgBackupConfig(Request $request, Response $response, array $args) : Response {
$this->dockerActionManager->deleteBorgBackupConfig();
return $response->withStatus(201)->withHeader('Location', '.');
}
public function SystemPrune(Request $request, Response $response, array $args) : Response {
// Get streaming response start and closure
$nonbufResp = $this->startStreamingResponse($response);

View File

@@ -145,6 +145,27 @@ readonly class DockerActionManager {
}
}
public function deleteBorgBackupConfig(): void {
// Delete the borgbackup container
$id = 'nextcloud-aio-borgbackup';
$borgbackupContainer = $this->containerDefinitionFetcher->GetContainerById($id);
$this->DeleteContainer($borgbackupContainer);
// Delete the borg cache volume
$url = $this->BuildApiUrl('volumes/nextcloud_aio_backup_cache');
try {
$this->guzzleClient->delete($url);
error_log('nextcloud_aio_backup_cache volume deleted successfully.');
} catch (RequestException $e) {
if ($e->getCode() !== 404) {
error_log('Could not delete nextcloud_aio_backup_cache volume: ' . $e->getMessage());
}
}
// Clear the configuration variables and files
$this->configurationManager->deleteBorgBackupLocationItems();
}
public function GetLogs(string $id, string $since = ''): string {
$url = $this->BuildApiUrl(
sprintf(

View File

@@ -566,8 +566,7 @@
{% endif %}
is wrong or if you want to reset the backup location due to other reasons, you can do so by clicking on the button below.
</p>
<form method="POST" action="api/configuration" class="xhr">
<input type="hidden" name="delete_borg_backup_location_vars" value="yes"/>
<form method="POST" action="api/docker/backup-reset-location" class="xhr">
<input type="hidden" name="{{csrf.keys.name}}" value="{{csrf.name}}">
<input type="hidden" name="{{csrf.keys.value}}" value="{{csrf.value}}">
<input type="submit" value="Reset backup location" data-confirm='Are you sure that you want to reset the backup location?' />