# ============================================================================ # 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 | |
---|---|---|---|---|---|
#1 | 23960 | noe_gonzalez | "Forking branch Dev of perforce-software-sdp to noe_gonzalez-sdp." | ||
//guest/perforce_software/sdp/dev/Server/Windows/p4/common/bin/upgrade.ps1 | |||||
#2 | 22921 | Robert Cowham | Check for admin privileges when running as need to stop/start service | ||
#1 | 22919 | Robert Cowham |
Refacto sdp-functions Convert upgrade.bat into upgrade.ps1 Fix issue with p4verify.ps1 |