Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions distributions/openhab/src/main/resources/bin/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -637,10 +637,16 @@ Function Update-openHAB() {
Write-Host -ForegroundColor Cyan "Creating backup directories in $TempBackupDir"
DeleteIfExists $TempBackupDir $True

Write-Host -ForegroundColor Cyan "Copying directory conf, userdata and runtime to $TempBackupDirConf"
Copy-Item -Path $OHConf, $OHUserData, $OHRuntime -Destination $TempBackupDir -Recurse -Force -ErrorAction Stop
Write-Host -ForegroundColor Cyan "Copying directory conf, userdata and runtime to $TempBackupDir"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the text should be adapted....

New-Item -Path $TempBackupDir -Name "conf" -ItemType "Directory"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$TempBackupDir was just removed above, so it does not normally exist when this tries to create conf relative to it.

Pre-creating $TempBackupDirConf also changes the semantics of the following Copy-Item: when the destination directory already exists, copying $OHConf can create another directory level below it.

The existing CreateDirectory helper could keep this simpler:

CreateDirectory $TempBackupDir

Copy-Item -Path $OHConf -Destination $TempBackupDirConf -Recurse -Force -ErrorAction Stop
Copy-Item -Path $OHUserData -Destination $TempBackupDirUserData -Recurse -Force -ErrorAction Stop
Copy-Item -Path $OHRuntime -Destination $TempBackupDirRuntime -Recurse -Force -ErrorAction Stop

CreateDirectory $TempBackupDirHome

This still gives the backup the fixed conf, userdata, and runtime names expected by the restore logic, independent of the configured source directory names.

Copy-Item -Path $OHConf -Destination $TempBackupDirConf -Recurse -Force -ErrorAction Stop
New-Item -Path $TempBackupDir -Name "userdata" -ItemType "Directory"
Copy-Item -Path $OHUserData -Destination $TempBackupDirUserData -Recurse -Force -ErrorAction Stop
New-Item -Path $TempBackupDir -Name "runtime" -ItemType "Directory"
Copy-Item -Path $OHRuntime -Destination $TempBackupDirRuntime -Recurse -Force -ErrorAction Stop

Write-Host -ForegroundColor Cyan "Copying files from $OHDirectory to $TempBackupDirHome"
New-Item -Path $TempBackupDir -Name "home" -ItemType "Directory"
Get-ChildItem $OHDirectory -File -ErrorAction Stop | Copy-Item -Destination $TempBackupDirHome -Force -ErrorAction Stop

} catch {
Expand Down