Move creation of root directory to before addhostname check, and create

subdir if neede
This commit is contained in:
Daniel Lysfjord 2026-03-05 19:48:39 +01:00
parent 02ec4f56eb
commit d1666413aa

View file

@ -467,10 +467,6 @@ class Nextcloud extends Base implements IBackupProvider
$keep_days = $nextcloud->numdays->getValue();
$keep_num = $nextcloud->numbackups->getValue();
if ($nextcloud->addhostname->isEqual('1')) {
$backupdir .= "/" . gethostname();
}
// Check if destination directory exists, create (full path) if not
try {
$internal_username = $this->getInternalUsername($url, $username, $password);
@ -479,6 +475,18 @@ class Nextcloud extends Base implements IBackupProvider
return array();
}
if ($nextcloud->addhostname->isEqual('1')) {
$backupdir .= "/" . gethostname();
# Since we have a new backupdir, create this too, if needed
try {
$this->create_directory($url, $username, $password, $internal_username, $backupdir);
} catch (\Exception $e) {
syslog(LOG_ERR, "nextcloud backup failed: " . $e);
return array();
}
}
if ($strategy) {
$list_of_files = $this->backupstrat_one($internal_username, $username, $password, $url, $backupdir, $crypto_password);
} else {