Make borg_remote_repo an attribute

Signed-off-by: Pablo Zmdl <pablo@nextcloud.com>
This commit is contained in:
Pablo Zmdl 2026-01-19 12:14:39 +01:00
parent 4d246add8a
commit 6df0333f71
3 changed files with 12 additions and 16 deletions

View file

@ -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(),

View file

@ -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 "";

View file

@ -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' : '',