diff --git a/php/public/index.php b/php/public/index.php index eb214eff..16d274f9 100644 --- a/php/public/index.php +++ b/php/public/index.php @@ -94,7 +94,7 @@ $app->get('/containers', function (Request $request, Response $response, array $ 'domain' => $configurationManager->domain, 'apache_port' => $configurationManager->GetApachePort(), 'borg_backup_host_location' => $configurationManager->borg_backup_host_location, - 'borg_remote_repo' => $configurationManager->GetBorgRemoteRepo(), + 'borg_remote_repo' => $configurationManager->borg_remote_repo, 'borg_public_key' => $configurationManager->GetBorgPublicKey(), 'nextcloud_password' => $configurationManager->GetAndGenerateSecret('NEXTCLOUD_PASSWORD'), 'containers' => (new \AIO\ContainerDefinitionFetcher($container->get(\AIO\Data\ConfigurationManager::class), $container))->FetchDefinition(), diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 1c93f51b..5dea0c6d 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -114,6 +114,11 @@ class ConfigurationManager set { $this->set('borg_backup_host_location', $value); } } + public string $borg_remote_repo { + get => $this->get('borg_remote_repo', ''); + set { $this->set('borg_remote_repo', $value); } + } + public function GetConfig() : array { if ($this->config === [] && file_exists(DataConst::GetConfigFile())) @@ -384,10 +389,10 @@ class ConfigurationManager $this->ValidateBorgLocationVars($location, $repo); $config = $this->GetConfig(); - $config['borg_remote_repo'] = $repo; $this->WriteConfig($config); - $this->setMultiple(function ($confManager) use ($location) { + $this->setMultiple(function ($confManager) use ($location, $repo) { $confManager->borg_backup_host_location = $location; + $confManager->borg_remote_repo = $repo; }); } @@ -435,10 +440,10 @@ class ConfigurationManager public function DeleteBorgBackupLocationItems() : void { // Delete the variables $config = $this->GetConfig(); - $config['borg_remote_repo'] = ''; $this->WriteConfig($config); $this->setMultiple(function ($confManager) { $confManager->borg_backup_host_location = ''; + $confManager->borg_remote_repo = ''; }); // Also delete the borg config file to be able to start over @@ -460,12 +465,12 @@ class ConfigurationManager } $config = $this->GetConfig(); - $config['borg_remote_repo'] = $repo; $config['borg_restore_password'] = $password; $this->WriteConfig($config); - $this->setMultiple(function ($confManager) use ($location) { + $this->setMultiple(function ($confManager) use ($location, $repo) { $confManager->borg_backup_host_location = $location; + $confManager->borg_remote_repo = $repo; $confManager->instance_restore_attempt = true; }); } @@ -565,15 +570,6 @@ class ConfigurationManager return $envVariableOutput; } - public function GetBorgRemoteRepo() : string { - $config = $this->GetConfig(); - if(!isset($config['borg_remote_repo'])) { - $config['borg_remote_repo'] = ''; - } - - return $config['borg_remote_repo']; - } - public function GetBorgPublicKey() : string { if (!file_exists(DataConst::GetBackupPublicKey())) { return ""; diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index a3ea0c9b..876dd805 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -560,7 +560,7 @@ readonly class DockerActionManager { 'NC_DOMAIN' => $this->configurationManager->GetDomain(), 'NC_BASE_DN' => $this->configurationManager->GetBaseDN(), 'AIO_TOKEN' => $this->configurationManager->AIO_TOKEN, - 'BORGBACKUP_REMOTE_REPO' => $this->configurationManager->GetBorgRemoteRepo(), + 'BORGBACKUP_REMOTE_REPO' => $this->configurationManager->borg_remote_repo, 'BORGBACKUP_MODE' => $this->configurationManager->GetBackupMode(), 'AIO_URL' => $this->configurationManager->AIO_URL, 'RESTORE_EXCLUDE_PREVIEWS' => $this->configurationManager->restoreExcludePreviews ? '1' : '',