#!/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 designed to create a seed checkpoint for an Edge server.
#
# An edge server is naturally filtered, with certain database tables (e.g.
# db.have) excluded. In addition to implicit filtering, the server spec may
# specify additional tables to be excluded, e.g. by using the
# ArchiveDataFilter field of the server spec.
#
# The script requires the SDP instance and the edge ServerID.
# Run example:
# ./edge_dump.sh 1 p4d_edge_syd
set -u
declare EdgeSeedCheckpoint=
declare ExcludedTables=
declare DumpCmd=
function usage () {
echo -e "Usage:\n\t${0##*/} <SDP_Instance> <ServerID>\n"
exit 1
}
[[ $# -ne 2 || ${1:-Unset} == -h ]] && usage
export SDP_INSTANCE=${SDP_INSTANCE:-Undefined}
export SDP_INSTANCE=${1:-$SDP_INSTANCE}
if [[ $SDP_INSTANCE == Undefined ]]; then
echo -e "Usage Error: Instance parameter not supplied."
usage
fi
declare ServerID=${2:-Unset}
if [[ $ServerID == Unset ]]; then
echo -e "Usage Error: ServerID parameter not supplied."
usage
fi
#shellcheck disable=SC1091
source /p4/common/bin/p4_vars "$SDP_INSTANCE"
#shellcheck disable=SC1091
source /p4/common/bin/backup_functions.sh
#shellcheck disable=SC1091
source /p4/common/bin/edge_vars
LOGFILE="$LOGS/edge_dump.$(date +'%Y%m%d-%H%M').log"
######### Start of Script ##########
echo "Processing. This may take a while depending on checkpoint duration."
echo "Log file is: $LOGFILE"
check_vars
set_vars
check_offline_db_usable
get_offline_journal_num
if [[ "$(is_edge "$ServerID" "$OFFLINE_DB")" == YES ]]; then
log "Verified: Server $ServerID is an edge server."
else
die "Could not confirm that $ServerID is an edge server."
fi
[[ -n "$ExcludedTables" ]] &&\
die "Value for \$ExludedTables not defined in $P4CBIN/edge_vars."
ckp_running
EdgeSeedCheckpoint=${CHECKPOINTS}/${P4SERVER}.${ServerID#p4d_}.seed.$OFFLINEJNLNUM.gz
DumpCmd="$P4DBIN -r $OFFLINE_DB -K $ExcludedTables -P $ServerID -jd -z $EdgeSeedCheckpoint"
log "Create edge seed checkpoint from master offline_db skipping edge-local tables and using the edge server form for any filtered data."
log "Running: $DumpCmd"
{ time $DumpCmd ; } >> "$LOGFILE" 2>&1 || { die "Edge seed checkpoint dump failed!"; }
log "Edge seed checkpoint complete."
# Inform the user about follow up tasks
log "You now need to copy $EdgeSeedCheckpoint to the edge server and use /p4/common/bin/recover_edge.sh to reseed the edge server."
ckp_complete
cat "$LOGFILE"
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #9 | 32135 | C. Thomas Tyler |
Released SDP 2025.1.32133 (2025/10/29). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
| #8 | 30915 | C. Thomas Tyler |
Released SDP 2024.1.30913 (2024/11/20). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
| #7 | 27331 | C. Thomas Tyler |
Released SDP 2020.1.27325 (2021/01/29). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
| #6 | 25951 | C. Thomas Tyler |
Released SDP 2019.2.25949 (2019/08/12). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
| #5 | 25940 | C. Thomas Tyler |
Released SDP 2019.2.25938 (2019/08/05). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
| #4 | 25933 | C. Thomas Tyler |
Released SDP 2019.2.25923 (2019/08/05). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
| #3 | 23331 | C. Thomas Tyler |
Released SDP 2017.4.23329 (2017/12/05). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
| #2 | 23006 | C. Thomas Tyler |
Released SDP 2017.3.23003 (2017/10/19). Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'. |
||
| #1 | 22685 | Russell C. Jackson (Rusty) | Update main with current changes from dev. | ||
| //guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/edge_dump.sh | |||||
| #3 | 22617 | Russell C. Jackson (Rusty) | Added +x | ||
| #2 | 22615 | Russell C. Jackson (Rusty) |
Added suggested comments. By passing review since this is a comment only change. |
||
| #1 | 22614 | Russell C. Jackson (Rusty) |
New script to create a filtered checkpoint to use to rebuild an edge server. This is not required unless you are filtering data via the server spec. If you are not doing that, then you can reseed the edge using the latest checkpoint of the master. |
||