openhab-distro icon indicating copy to clipboard operation
openhab-distro copied to clipboard

update.ps1 Backup not created correctly during update on Windows

Open yndtrud opened this issue 10 months ago • 0 comments

As far as I understand the logic of the process:

  1. create folder in user temp backup-3.4.5 (current version)
  2. copy folders conf, runtime, userdata to backup-3.4.5 ( backup-3.4.5\conf, backup-3.4.5\runtime, backup-3.4.5\userdata)
  3. copy files from openhab root folder to backup-3.4.5\home folder

You can launch any 3.2.x+ or 4.x.x update script and you get: On step 2: backup-3.4.5 with content of conf folder + runtime and userdata subfolder

  • runtime
  • userdata
  • automation
  • html
  • icons
  • items
  • persistence
  • rules
  • scripts
  • services
  • sitemaps
  • sounds
  • things
  • transform On step 3: in folder backup-3.4.5 there will be a home file with the contents of the start.sh file!

` # Crete the temporary backup locations to the current distribution $TempBackupDir = "$TempDir\backup-$CurrentVersion" $TempBackupDirHome = $TempBackupDir + "\home" $TempBackupDirRuntime = $TempBackupDir + "\runtime" $TempBackupDirUserData = $TempBackupDir + "\userdata" $TempBackupDirConf = $TempBackupDir + "\conf"

# Backup the current distribution to those locations
Write-Host ""
Write-Host -ForegroundColor Cyan "Making a backup of your distribution to $TempBackupDir"
try {
    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 files from $OHDirectory to $TempBackupDirHome"
    Get-ChildItem $OHDirectory -File -ErrorAction Stop | Copy-Item -Destination $TempBackupDirHome -Force -ErrorAction Stop

} catch {
    exit PrintAndReturn "Could not backup existing distribution to $TempBackupDir" $_
}

`

As a result, update.ps1 cannot return the state from the backup if the update installation fails (cannot find folders in backup 3.4.5).

And since update.ps1 on Windows cannot correctly call updatetools.jar, from version 3.4.5 to version 4.0.0, 4.0.1, 4.0.2 I update manually. The script is completely broken.

yndtrud avatar Sep 06 '23 10:09 yndtrud