#!/bin/bash #============================================================================== # 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 #------------------------------------------------------------------------------ export SDP_INSTANCE=${SDP_INSTANCE:-Undefined} export SDP_INSTANCE=${1:-$SDP_INSTANCE} if [[ $SDP_INSTANCE == Undefined ]]; then echo "Instance parameter not supplied." echo "You must supply the Perforce instance as a parameter to this script." exit 1 fi source /p4/common/bin/p4_vars "$SDP_INSTANCE" source /p4/common/bin/backup_functions.sh export LOGFILE=$LOGS/p4verify.log check_vars set_vars rotate_log_file "$LOGFILE" ".gz" log "Start $P4SERVER Verify (RAM-Optimized)" StatusMessage="OK: All scanned depots verified OK." declare -i ExitCode=0 P4="$P4BIN -p ${P4PORT} -u $P4USER" /p4/common/bin/p4login echo "If there are errors in this log, contact support@perforce.com" >> $LOGFILE # Verify each depot of type 'local', ignoring remote depots. for d in `$P4 -s depots|grep "^info: Depot " | cut -d" " -f3,5 | \ egrep -v 'archive$|remote$' | cut -d" " -f1 ` ; do depot_type=$($P4 -ztag -F %Type% depot -o $d) log "\n=== Started verify of //$d/... ===" if [[ "$depot_type" != "unload" ]]; then # Verify submitted archive files with the 'p4verify.pl' script that # incrementally verifies a potentially massive amount of archive files, # but in a way that avoids using much RAM due to using a recursive # directory-tree walking algorithm. The 'p4verify.pl' script applies # the '-t' flag to 'p4 verify' if running on a replica. echo Running: /p4/common/bin/p4verify.pl //$d/... >> $LOGFILE 2>&1 /p4/common/bin/p4verify.pl "//$d/..." >> $LOGFILE 2>&1 if [[ "$depot_type" != "spec" ]]; then # Verify shelved files all at once, as they verify much more quickly. log "Verifying Shelves" if [[ "${P4REPLICA}" == "FALSE" ]]; then echo Running: $P4 -s verify -qS //$d/... >> $LOGFILE $P4 -s verify -qS //$d/... >> $LOGFILE 2>&1 else echo Running: $P4 -s verify -t -qS //$d/... >> $LOGFILE $P4 -s verify -t -qS //$d/... >> $LOGFILE 2>&1 fi fi else if [[ "${P4REPLICA}" == "FALSE" ]]; then echo Running: $P4 -s verify -U -q //$d/... >> $LOGFILE $P4 -s verify -U -qz //$d/... >> $LOGFILE 2>&1 else echo Running: $P4 -s verify -U -q -t //$d/... >> $LOGFILE $P4 -s verify -U -qz -t //$d/... >> $LOGFILE 2>&1 fi fi done egrep -m1 '(BAD!|MISSING!|p4 help max)' "$LOGFILE" > /dev/null 2>&1 if [[ $? -eq 0 ]]; then StatusMessage="Warning: Verify errors detected. Review the log [$Log]." ExitCode=1 fi log "$StatusMessage" echo -e "\nCompleted verifications at $(date)\n\nThat took $(($SECONDS/3600)) hours $(($SECONDS%3600/60)) minutes $(($SECONDS%60)) seconds.\n" mail_log_file "$HOSTNAME $P4SERVER P4Verify Log ($StatusMessage)" exit $ExitCode
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 24665 | C. Thomas Tyler | Latest versions. | ||
#1 | 24658 | C. Thomas Tyler |
Added modernized versions of 'p4 verify' scripts that do a low-memory verification of everything. Good for use on massive data sets on servers without enough RAM to do a one-pass verify like: 'p4 verify -qz //some_big_depot/...'. |