A few days ago I streamed how I try to upgrade a Business Central CRONOS Database just using docker:
Apart from a few throwbacks it went quite well, but better watch yourself 😉
However, I promised to publish the script I created so you don’t need to write it down from the video.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ContainerNameOld = 'BC17-dev' | |
$ContainerNameNew = 'BC18-dev' | |
$TargetVersionBasePath = 'C:\bcartifacts.cache\onprem\18.0.23013.23795' | |
$BackFolderName = 'C:\ProgramData\BcContainerHelper\DatabaseUpgrade\' | |
$BackFile17 = Join-Path $BackFolderName 'Database_17.bak' | |
# Unsinstall all Extensions | |
Get-BcContainerAppInfo –containerName $ContainerNameOld | ForEach-Object { UnInstall-BcContainerApp –containerName $ContainerNameOld –Name $_.Name –Version $_.Version –Force } | |
# Unintall all 'Symbols only' extensions | |
Get-BcContainerAppInfo –containerName $ContainerNameOld –SymbolsOnly | ForEach-Object { Unpublish-BcContainerApp –containerName $ContainerNameOld –Name $_.Name –Version $_.Version } | |
# Backup the database from docker container to docker host | |
Backup-BcContainerDatabases –containerName $ContainerNameOld –bakFolder $BackFolderName | |
#Stop the BC service in the target version container | |
Invoke-ScriptInBcContainer –containerName $ContainerNameNew –scriptblock { | |
Stop-NAVServerInstance –ServerInstance BC | |
} | |
# restore the database which should be upgraded to the target version docker container | |
Restore-DatabasesInBcContainer –containerName $ContainerNameNew –bakFile $BackFile17 | |
Invoke-ScriptInBcContainer –containerName $ContainerNameNew –scriptblock { | |
$DatabaseName = 'Database_17' | |
Write-Host "Database conversion started" | |
Invoke-NAVApplicationDatabaseConversion –DatabaseServer localhost –DatabaseName $DatabaseName | |
Write-Host "Set the database name to point to the old version database" | |
Set-NAVServerConfiguration –ServerInstance BC –KeyName DatabaseName –KeyValue $DatabaseName | |
Write-Host "Disable the task scheduler" | |
Set-NavServerConfiguration –ServerInstance BC –KeyName "EnableTaskScheduler" –KeyValue false | |
Write-Host "Restart BC server instance" | |
Restart-NAVServerInstance –ServerInstance BC | |
# Technical upgrade only | |
# Get-NAVAppInfo -ServerInstance BC | Repair-NAVApp | |
# Restart-NAVServerInstance -ServerInstance BC | |
} | |
# Publish the new app versions | |
# If your target is not BC18 you need the adjust the path ####### here ####### | |
Publish-BcContainerApp –containerName $ContainerNameNew –appFile (Join-Path $TargetVersionBasePath "\platform\ModernDev\program files\Microsoft Dynamics NAV\180\AL Development Environment\System.app") –PackageType SymbolsOnly | |
Publish-BcContainerApp –containerName $ContainerNameNew –appFile (Join-Path $TargetVersionBasePath "\de\Applications\System Application\Source\Microsoft_System Application.app") | |
Publish-BcContainerApp –containerName $ContainerNameNew –appFile (Join-Path $TargetVersionBasePath "\de\Applications\BaseApp\Source\Microsoft_Base Application.app") | |
Publish-BcContainerApp –containerName $ContainerNameNew –appFile (Join-Path $TargetVersionBasePath "\de\Applications\Application\Source\Microsoft_Application.app") | |
# Sync apps and start their data upgrade | |
Invoke-ScriptInBcContainer –containerName $ContainerNameNew –scriptblock { | |
$NewVersion = '18.0.23013.23795' | |
Sync-NAVTenant –ServerInstance BC –Tenant default –Mode Sync | |
Sync-NAVApp –ServerInstance BC –Tenant default –Name "System Application" –Version $NewVersion –Mode ForceSync | |
Sync-NAVApp –ServerInstance BC –Tenant default –Name "Base Application" –Version $NewVersion –Mode ForceSync | |
Sync-NAVApp –ServerInstance BC –Tenant default –Name "Application" –Version $NewVersion –Mode ForceSync | |
Start-NAVAppDataUpgrade –ServerInstance BC –Name "System Application" –Version $NewVersion | |
Start-NAVAppDataUpgrade –ServerInstance BC –Name "Base Application" –Version $NewVersion | |
} | |
# Lines 30 – 44 can be adapted to upgrade other MS extensions as well | |
# If you have custom extensions or other ISV or third party extensions you would want to upgrade them as well using these steps | |
# Get-BcContainerAppInfo -containerName $ContainerNameNew -SymbolsOnly | |
### After upgrade ### | |
Invoke-ScriptInBcContainer –containerName $ContainerNameNew –scriptblock { | |
Set-NavServerConfiguration –ServerInstance BC –KeyName "EnableTaskScheduler" –KeyValue true | |
Restart-NAVServerInstance –ServerInstance BC | |
} |
Have Fun 😉
Imagine there would be a Cmdlet in the BcContainerHelper to perform a CU /Minor Update.
Some pieces need to be parametrization, but doesn’t looks impossible.
LikeLiked by 2 people
Indeed, I’m trying it based with findings from this https://github.com/microsoft/navcontainerhelper/issues/2223
No luck so far, it has trouble finding the external database in the target container.
LikeLike
Should it not be Cronus instead of Cronos? 😉
LikeLiked by 1 person
Hello Stefan,
Thanks for this video. It seems to be easy and fast when you explain the upgrade process.
I tried your script between version 20.1 and 20.2 but I have the following issue when i used the Invoke-NAVApplicationDatabaseConversion
A technical upgrade of database ‘database’ on server ‘LOCALHOST’ cannot be run, because the database�s application version ‘131250’ is greater than or equal to the platform versio
n ‘131250’.
Do you have a suggestion 😉 ?
Steven.
LikeLike
AFAIK, Not all minor upgrades require a database conversion. At least it was like this in the old NAV days. It could be that you can just skip that step 🙂
LikeLike
Yes, i finally i understood and i done exactly that.
Thanks.
LikeLike
Please note that in the script (line 49/50/51) the /de/ is specific for germany. This should be changed to your country
Is it possible to do the same with external databases. I think you are using an database inside the container;
LikeLike
Did you re-run your scripts . I tried this step by step, but i get the same error as in the video on publishing the first app again that the version already exists. And also have a crash when trying to publish the 3thrd.
I like the idea
LikeLike