# ============================================================================ # Copyright and license info is available in the LICENSE file included with # the Server Deployment Package (SDP), and also available online: # https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE # ---------------------------------------------------------------------------- <# .Synopsis upgrade.ps1 performs upgrades the specified Perforce SDP instance to a new version of p4d .Description Rotates the journal, stops the live service, updates the executable, updates the offline and root databases, and restarts the service .Parameter sdp-instance The specified SDP instance to verify .Example upgrade.ps1 Master .Example upgrade.ps1 1 #> [CmdletBinding()] param ([string]$SDPInstance = $(throw "SDPInstance parameter is required.")) Set-StrictMode -Version 2.0 # Source the SDP Functions shared between scripts $SDPFunctionsPath = Split-Path -parent $MyInvocation.MyCommand.Path | Join-Path -childpath "SDP-Functions.ps1" . $SDPFunctionsPath $global:ScriptName = "Upgrade.ps1" $global:ScriptTask = "Upgrade" $global:LogFileName = "upgrade.log" Parse-SDPConfigFile $MyInvocation.MyCommand.Path Create-LogFile $OrigPath = convert-path . Set-Location -Path $global:LOGS_DIR Function Run-Upgrade () { Log "Running upgrade" $p4 = -join($global:SCRIPTS_DIR, "\p4.exe") $p4d = -join($global:SCRIPTS_DIR, "\p4d.exe") Ensure-PathExists $p4 Ensure-PathExists $p4d set-vars $is_replica = is-replica Invoke-P4Login if (! $is_replica -or ! $global:EDGESERVER) { Get-CurrentJournalCounter } Stop-LiveService # Only rotate the journal on the master. if (! $is_replica -and ! $global:EDGESERVER) { Get-OfflineJournalCounter Truncate-Journal Rotate-Logfiles Replay-JournalsToOfflineDB } $p4s = -join($global:SDP_INSTANCE_BIN_DIR, "\p4s.exe") copy-files $p4 $global:SDP_INSTANCE_BIN_DIR copy-files $p4d $global:SDP_INSTANCE_BIN_DIR copy-files $p4d $p4s $cmd = "$global:P4dexe -r $global:p4root -J off -xu" run-cmd-with-check $cmd "ERROR - attempting to upgrade db" # Upgrade the offline database on the master and on edge servers. if (! $is_replica -or $global:EDGESERVER) { $cmd = "$global:P4dexe -r $global:offline_db_dir -J off -xu" run-cmd-with-check $cmd "ERROR - attempting to upgrade db" } Start-LiveService } try { Check-AdminPrivileges Log "If there are errors in this log, you may wish to contact support@perforce.com for help." Invoke-P4Login Run-Upgrade Remove-OldLogs Log "End ${global:SDP_INSTANCE_P4SERVICE_NAME} ${global:ScriptTask}" Send-Email "${env:computername} ${global:SDP_INSTANCE_P4SERVICE_NAME} ${global:ScriptTask} log." Write-Output "`r`n${global:ScriptTask} completed successfully - see ${global:logfile}" } Catch { write-error $error[0].ScriptStackTrace LogException $_.Exception Send-Email "FAILED: ${env:computername} ${global:SDP_INSTANCE_P4SERVICE_NAME} ${global:ScriptTask} log." Write-Output "`r`nFAILED - ${global:ScriptTask} - see ${global:logfile}" } Set-Location -Path $OrigPath
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 28858 | C. Thomas Tyler |
Released SDP 2022.1.28855 (2022/05/27). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#5 | 27331 | C. Thomas Tyler |
Released SDP 2020.1.27325 (2021/01/29). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#4 | 26246 | C. Thomas Tyler |
Released SDP 2019.3.26239 (2020/01/08). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#3 | 26161 | C. Thomas Tyler |
Released SDP 2019.3.26159 (2019/11/06). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
#2 | 22931 | Robert Cowham |
Updated docs for Windows. New rotate-log-files script. Working upgrade.ps1 |
||
#1 | 22920 | Robert Cowham |
Bring latest changes in from dev for Windows. - fixed p4verify for replicas with -t - created upgrade.ps1 |
||
//guest/perforce_software/sdp/dev/Server/Windows/p4/common/bin/upgrade.ps1 | |||||
#1 | 22919 | Robert Cowham |
Refacto sdp-functions Convert upgrade.bat into upgrade.ps1 Fix issue with p4verify.ps1 |