# ============================================================================ # 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 p4verify.ps1 performs archive verification on all appropriate depots .Description Runs "p4 verify -qz //depot/..." as appropriate. .Parameter sdp-instance The specified SDP instance to verify .Example p4verify.ps1 Master .Example p4verify.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 = "P4Verify.ps1" $global:ScriptTask = "Verify" $global:LogFileName = "p4verify.log" Parse-SDPConfigFile $MyInvocation.MyCommand.Path Create-LogFile $OrigPath = convert-path . Set-Location -Path $global:LOGS_DIR Function Run-Verify () { Log "Running verify" #$depots = & $global:P4exe -p $global:P4PORT -u $global:SDP_P4SUPERUSER depots 2>&1 $depots = & $global:P4exe -p $global:P4PORT -u $global:SDP_P4SUPERUSER depots 2>&1 Log $depots if ($lastexitcode -ne 0) { throw "ERROR - failed to get depots!" } # If a replica then add -t for transfer to args $replica_args = "" if (is-replica) { $replica_args = "-t" } foreach ($dline in $depots) { $dname = $dline.split()[1] $dtype = $dline.split()[3] Log "$dname has type $dtype" if (!($dtype -match "remote|archive")) { if ($dtype -match "unload") { $cmd = "$global:P4exe -p $global:P4PORT -s -u $global:SDP_P4SUPERUSER verify -U -q $replica_args //$dname/... >> $global:LogFile 2>&1" Log $cmd cmd /c $cmd } else { $cmd = "$global:P4exe -p $global:P4PORT -s -u $global:SDP_P4SUPERUSER verify -qz $replica_args //$dname/... >> $global:LogFile 2>&1" Log $cmd cmd /c $cmd $cmd = "$global:P4exe -p $global:P4PORT -s -u $global:SDP_P4SUPERUSER verify -qS $replica_args //$dname/... >> $global:LogFile 2>&1" Log $cmd cmd /c $cmd } } } # Finally we check for errors $matches = Get-Content $global:logfile | Select-String -Pattern "BAD!|MISSING!" -AllMatches if ($matches -ne $null) { $count = $matches.matches.count if ($count -gt 0) { throw "Found $count verify errors in logfile - contact support@perforce.com if you need help to resolve" } } } try { Log "If there are errors in this log, you may wish to contact support@perforce.com for help." Invoke-P4Login Run-Verify 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/p4verify.ps1 | |||||
#4 | 22919 | Robert Cowham |
Refacto sdp-functions Convert upgrade.bat into upgrade.ps1 Fix issue with p4verify.ps1 |
||
#3 | 22917 | Robert Cowham | Add -t flag to verify for replicas | ||
#2 | 21884 | C. Thomas Tyler | Merge down of hot fix (@21851) to fix Windows Powershell p4verify.ps1 script. | ||
#1 | 21602 | Robert Cowham | Add p4verify.ps1 |