nextcloud/all-in-one · error · InvalidSettingConfigurationException

Location and remote repo url are mutually exclusive!

Error message

Location and remote repo url are mutually exclusive!

What it means

validateBorgLocationVars() in ConfigurationManager rejects requests where both a local backup path and a borg remote repository URL are provided — they are mutually exclusive because borg either writes to a mounted path or to a remote repository, never both. Throws InvalidSettingConfigurationException → HTTP 422 in the AIO UI. Reached from the backup settings form (setBorgLocationVars) and the restore form.

Source

Thrown at php/src/Data/ConfigurationManager.php:731

        return 'dc=' . implode(',dc=', explode('.', $domain));
    }

    /**
     * @throws InvalidSettingConfigurationException
     */
    public function setBorgLocationVars(string $location, string $repo) : void {
        $this->validateBorgLocationVars($location, $repo);
        $this->startTransaction();
        $this->borgBackupHostLocation = $location;
        $this->borgRemoteRepo = $repo;
        $this->commitTransaction();
    }

    private function validateBorgLocationVars(string $location, string $repo) : void {
        if ($location === '' && $repo === '') {
            throw new InvalidSettingConfigurationException("Please enter a path or a remote repo url!");
        } elseif ($location !== '' && $repo !== '') {
            throw new InvalidSettingConfigurationException("Location and remote repo url are mutually exclusive!");
        }

        if ($location !== '') {
            $isValidPath = false;
            if (str_starts_with($location, '/') && !str_ends_with($location, '/')) {
                $isValidPath = true;
            } elseif ($location === 'nextcloud_aio_backupdir') {
                $isValidPath = true;
            }

            if (!$isValidPath) {
                throw new InvalidSettingConfigurationException("The path must start with '/', and must not end with '/'! Another option is to use the docker volume name 'nextcloud_aio_backupdir'.");
            }

            // Prevent backup to be contained in Nextcloud Datadir as this will delete the backup archive upon restore
            // See https://github.com/nextcloud/all-in-one/issues/6607
            if (str_starts_with($location . '/', rtrim($this->nextcloudDatadirMount, '/') . '/')) {
                throw new InvalidSettingConfigurationException("The path must not be a children of or equal to NEXTCLOUD_DATADIR, which is currently set to " . $this->nextcloudDatadirMount);

View on GitHub (pinned to 6b788eec5e)

Solutions

  1. Decide on one target and clear the other field before submitting
  2. For local backups keep only the path; for remote keep only the repo URL
  3. When switching permanently, submit the new value with the other field left empty — setBorgLocationVars stores both, emptying the unused one

Example fix

// before
borg_backup_host_location = '/mnt/backup'
borg_remote_repo = 'ssh://user@host/./repo'
// after
borg_backup_host_location = ''
borg_remote_repo = 'ssh://user@host/./repo'
Defensive patterns

Strategy: validation

Validate before calling

if (trim($location) !== '' && trim($repo) !== '') {
    $errors[] = 'Choose either a local path or a remote repo url, not both';
}

Try / catch

use AIO\Data\InvalidSettingConfigurationException;

try {
    $configurationManager->setBorgLocationVars($location, $repo);
} catch (InvalidSettingConfigurationException $e) {
    $formErrors[] = $e->getMessage();
}

Prevention

When it happens

Trigger: POST with borg_backup_host_location='/mnt/backup' and borg_remote_repo='ssh://user@host/./repo' at the same time; switching from local to remote backup by filling the new field but leaving the old value in place.

Common situations: Users migrating from local backups to a remote repository; forms that keep both inputs filled from previous state.

Related errors


AI-assisted analysis of nextcloud/all-in-one@6b788eec5e (2026-08-21). Data as JSON: /api/errors/6363efb9f4eb02a7. Report an issue: GitHub.