Upgrade a BC CRONUS Database using Docker

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.

$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 😉

2 thoughts on “Upgrade a BC CRONUS Database using Docker

  1. 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.

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: