# ============================================================================ # 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" #$result = & $global:P4exe -p $global:P4PORT -u $global:SDP_P4SUPERUSER depots 2>&1 $result = & $global:P4exe -p $global:P4PORT -u $global:SDP_P4SUPERUSER depots 2>&1 Log $result if ($lastexitcode -ne 0) { throw "ERROR - failed to get depots!" } foreach ($dline in $result) { $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 //$dname/... >> $global:LogFile 2>&1" Log $cmd cmd /c $cmd } else { $cmd = "$global:P4exe -p $global:P4PORT -s -u $global:SDP_P4SUPERUSER verify -qz //$dname/... >> $global:LogFile 2>&1" Log $cmd cmd /c $cmd $cmd = "$global:P4exe -p $global:P4PORT -s -u $global:SDP_P4SUPERUSER verify -qS //$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 | |
---|---|---|---|---|---|
#8 | 28771 | C. Thomas Tyler |
Changed email address for Perforce Support. #review-28772 @amo @robert_cowham |
||
#7 | 28642 | C. Thomas Tyler |
Added '-fast' flag to p4verify.ps1 quickly; uses '--only MISSING'. Added '-nt' flag to p4verify.ps1 to not add '-t' on a replica. If this change is approved/commited, next steps are: * Generate C:\p4\1\bin\p4verify-fast.bat * Generate C:\p4\common\bin\p4verify-fast.bat * Updated docs re: Scheduled Tasks to discuss options, e.g. Run the fast verify daily, and full verify weekly or monthly. I do not suggest adding separate *.bat wrappers for the '-nt' option, as that is an advanted option, probably not worth the clutter of extra files (and we'd need combinations with/without -fast). That '-nt' option can remain only an option to the PowerShell script. |
||
#6 | 26659 | Robert Cowham |
Removing out-of-date files and ancient utilities. Updating SDP Guide for Windows with includes to various .ps1 scripts Add new sync-replica.ps1 and call it from sync_replica.bat |
||
#5 | 26108 | Robert Cowham |
Whitepace fixed. No other change. |
||
#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 |