request_replica_checkpoint.sh #1

  • //
  • guest/
  • russell_jackson/
  • sdp/
  • Server/
  • Unix/
  • p4/
  • common/
  • bin/
  • request_replica_checkpoint.sh
  • View
  • Commits
  • Open Download .zip Download (3 KB)
#!/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
#------------------------------------------------------------------------------

# This script is intended to be run on a standby replica.  It essentially just
# calls 'p4 admin checkpoint -Z' to request a checkpoint and exits. The actual
# checkpoint is created on the next journal rotation on the master.
declare -i RequestNow=0

export SDP_INSTANCE="${SDP_INSTANCE:-Unset}"
export SDP_INSTANCE="${1:-$SDP_INSTANCE}"
if [[ "$SDP_INSTANCE" == Unset ]]; then 
   echo "Instance parameter not supplied." 
   echo "You must supply the Perforce instance as a parameter to this script." 
   exit 1 
fi

# The '-now' option is currently an undocumented feature, though it may be
# documented in a future release (pending a separate change to normalize command
# line processing to add '-h' and '-man' options across all key scripts).  If
# '-now' is specified, after requesting the checkpoint on the local replica/edge,
# the commit server is then contacted and a 'p4 admin journal' is attempted, thus
# starting the checkpoint process on the local edge immediately
[[ "${2:-}" == "-now" ]] && RequestNow=1

# shellcheck disable=SC1091
source /p4/common/bin/p4_vars "$SDP_INSTANCE"
# shellcheck disable=SC1091
source /p4/common/bin/backup_functions.sh
# shellcheck disable=SC2034
LOGFILE=$LOGS/request_checkpoint.log

######### Start of Script ##########
check_vars
set_vars
rotate_last_run_logs
log "Start $P4SERVER Replica Request Checkpoint"
check_uid
check_dirs

[[ "$P4MASTER_ID" == "$SERVERID" ]] && \
   die "Error: Do not run request_replica_checkpoint.sh on the commit server."

"$P4CBIN"/p4login
request_replica_checkpoint

if [[ "$RequestNow" -eq 1 ]]; then
   log "Requesting journal rotation on the commit server due to '-now'."
   # Use timeout here so we don't hang if there's a firewall block. This fork
   # logs into the commit server via the dedicated 'p4login_master' helper (its
   # 'p4login' targets only the local port).
   timeout 15s "$P4CBIN"/p4login_master >> "$LOGFILE" 2>&1 ||\
      die "The '-now' option was specified, but could not log in to the commit server ($P4MASTERPORT) via p4login_master."
   log "Running: $P4BIN -p $P4MASTERPORT admin journal"
   $P4BIN -p $P4MASTERPORT admin journal >> "$LOGFILE" 2>&1
fi

log "End $P4SERVER Replica Checkpoint"
mail_log_file "$HOSTNAME $P4SERVER replica request checkpoint log."
# Change User Description Committed
#1 32803 Russell C. Jackson (Rusty) Modernize russell_jackson SDP fork from upstream 2025.2.

- Port modern p4d features: partitioned/readonly clients, upgrade-safety (p4
  storage -w / p4 upgrades polling), checkpoint/replica/edge tooling, proxy &
  broker SSL trust, modern p4login, dir-ownership preflight.
- Add scripts: get_p4_binaries.sh (renamed from helix), ccheck.sh, verify_sdp.sh,
  sdp_health_check.sh, journal_watch.sh, load_checkpoint.sh, refresh_P4ROOT,
  request_replica_checkpoint.sh, keep_offline_db_current.sh, gen_sudoers.sh, etc.
- Migrate configurables to configurables.cfg applied via ccheck.sh -fix; slim
  configure_new_server.sh to setup-only.
- upgrade.sh: dry-run default, verified clean rollback point.
- Fixes from multi-agent review (rsync byte/KB+comma, cfg field counts, version
  thresholds, etc.).

See SDP_PORT_SCOPE.md for the full manifest.