Help me understand the manual update process

I am trying to script Lucee updates, using PowerShell, so I don’t have to manually log into the Lucee admin in all my servers and update them.

Do these steps sound correct? I am running Lucee 5.x on Windows.

  1. Stop the Lucee service
  2. Remove any old jar files from C:\lucee\lib (I found that if I left the old ones in there, the new one would not be applied when I restart Lucee)
  3. Copy the new jar file into C:\lucee\lib
  4. Start the Lucee service

This seems to work, the only downside is I cannot roll back to a previous version through the admin interface. I would like that ability.

It seems that if I:

  1. Stop the Lucee service again
  2. Copy the previously removed jar files back into C:\lucee\lib
  3. Start the Lucee service

Now I have the previous versions in the drop down in the update page in the Lucee admin. I have not scripted this last part (copying the old jar files back into c:\lucee\lib) because I’m afraid if I stop the Lucee service in my script, immediately after the start service command completes, that the update will not be finished being deployed.

Thoughts? Thanks.

Could just copy the old files to \MybackupPath\something-datetimestamp\luceeFiles
Could enable shadowcopies on the lucee lib folder and take a backup as part of your script

Yes, I am copying them to a backup location. But I’m not sure how to get them back in place with the script, due to needing to wait a while after the restart to let the update finishing deploying.

Maybe you are suggesting to just leave them in the backup location, then manually copy them in if I need to roll back. I think that is a 2nd best option. :+1:

Post your code for your script,

there are a few ways of doing just that in power shell.

1 if the latest backup for example was always c:\backup\the-latest-backup\ & all other backups are in c:\backup\archive\whatever you could add a function to your script, “restore-latest”

ie backup.ps1 --restoremyfiles

function Restore-MyFiles {
    param (
        [string]$sourcePath = "C:\backup\the-latest-backup",
        [string]$destinationPath = "C:\lucee\lib"
    )

    #### Check if the source directory exists
    if (-not (Test-Path -Path $sourcePath -PathType Container)) {
        Write-Host "Source directory does not exist: $sourcePath"
        return
    }

    ## Check if the destination directory exists
    if (-not (Test-Path -Path $destinationPath -PathType Container)) {
        Write-Host "Destination directory does not exist: $destinationPath"
        return
    }

    # Copy files from source to destination
    try {
        Copy-Item -Path "$sourcePath\*" -Destination $destinationPath -Recurse -Force
        Write-Host "Files restored successfully from $sourcePath to $destinationPath"
    } catch {
        Write-Host "Error restoring files: $_"
    }
}

# #Example use:
#Restore-MyFiles

1 Like