recover_edge.sh #6

  • //
  • guest/
  • perforce_software/
  • sdp/
  • main/
  • Server/
  • Unix/
  • p4/
  • common/
  • bin/
  • recover_edge.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 designed to rebuild an Edge server from a checkpoint of the master WHILE
# KEEPING THE EXISTING EDGE SPECIFIC DATA.
# You have to first copy the checkpoint from the master to the edge server before running this script.
# Then you run this script on the Edge server with the instance number and full path and filename
# of the master checkpoint as parameters.
#
# Run example:
#  ./recover_edge.sh 1 /depotdata/p4_1.ckp.9188.gz
 
if [[ "$1" == "" ]]; then
   echo You must pass in the instance number/ID as the first parameter to this script.
   exit 1
fi

if [[ "$2" == "" ]]; then
   echo You must pass in the full path and filename of the checkpoint you copied over from the master server.
   exit 2
fi

INSTANCE=$1
MASTERCKP=$2

rm -f /p4/${INSTANCE}/offline_db/db.*

# With -K we filter out the various Edge-specific tables which will be replaced with 
# current live versions.
EXCLUDED_TABLES=db.have,db.working,db.resolve,db.locks,db.revsh,db.workingx,db.resolvex

/p4/${INSTANCE}/bin/p4d_${INSTANCE} -r /p4/${INSTANCE}/offline_db/ -K $EXCLUDED_TABLES -jr -z $MASTERCKP

/p4/${INSTANCE}/bin/p4d_${INSTANCE}_init stop

# With -k we filter and only checkpoint the specified tables from the current live Edge DB.
CKP_TABLES=$EXCLUDED_TABLES,db.view,db.label,db.revsx,db.revux

/p4/${INSTANCE}/bin/p4d_${INSTANCE} -r /p4/${INSTANCE}/root/ -k $CKP_TABLES -jd /p4/${INSTANCE}/checkpoints/edgedump

# And apply those tables to the recreate offline_db
/p4/${INSTANCE}/bin/p4d_${INSTANCE} -r /p4/${INSTANCE}/offline_db -jr /p4/${INSTANCE}/checkpoints/edgedump

# Reset the various replication state files
rm -f /p4/${INSTANCE}/root/db.*
rm -f /p4/${INSTANCE}/root/state
rm -f /p4/${INSTANCE}/root/rdb.lbr
rm -f /p4/${INSTANCE}/logs/journal

# Should we remove root/db.*???
mv /p4/${INSTANCE}/offline_db/db.* /p4/${INSTANCE}/root/

/p4/${INSTANCE}/bin/p4d_${INSTANCE}_init start

# Recreate the offline_db as previously
/p4/${INSTANCE}/bin/p4d_${INSTANCE} -r /p4/${INSTANCE}/offline_db/ -K $EXCLUDED_TABLES -jr -z $MASTERCKP
/p4/${INSTANCE}/bin/p4d_${INSTANCE} -r /p4/${INSTANCE}/offline_db -jr /p4/${INSTANCE}/checkpoints/edgedump

# Checkpoint offline_db for posterity
/p4/${INSTANCE}/bin/p4d_${INSTANCE} -r /p4/${INSTANCE}/offline_db -jd -z /p4/${INSTANCE}/checkpoints/rebuilt_edge_dump.gz

# Inform the user about follow up tasks
echo Rebuilt checkpoint is: /p4/${INSTANCE}/checkpoints/rebuilt_edge_dump.gz
echo If you run this script the night before a recreate_db_checkpoint.sh is going to run, 
echo you need to delete the highest numbered checkpoint in /p4/${INSTANCE}/checkpoints
echo and rename /p4/${INSTANCE}/checkpoints/rebuilt_edge_dump.gz to replace that file.
# Change User Description Committed
#17 32135 C. Thomas Tyler Released SDP 2025.1.32133 (2025/10/29).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#16 30915 C. Thomas Tyler Released SDP 2024.1.30913 (2024/11/20).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#15 28240 C. Thomas Tyler Released SDP 2021.1.28238 (2021/11/12).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#14 27331 C. Thomas Tyler Released SDP 2020.1.27325 (2021/01/29).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#13 26496 C. Thomas Tyler Released SDP 2019.3.26494 (2020/04/23).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#12 25951 C. Thomas Tyler Released SDP 2019.2.25949 (2019/08/12).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#11 25940 C. Thomas Tyler Released SDP 2019.2.25938 (2019/08/05).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#10 25933 C. Thomas Tyler Released SDP 2019.2.25923 (2019/08/05).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#9 23331 C. Thomas Tyler Released SDP 2017.4.23329 (2017/12/05).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#8 23006 C. Thomas Tyler Released SDP 2017.3.23003 (2017/10/19).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#7 21338 C. Thomas Tyler Released SDP 2016.2.21328 (2016/12/16).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#6 19414 C. Thomas Tyler Released SDP/MultiArch/2016.1/19410 (2016/05/17).
#5 17315 C. Thomas Tyler Released SDP/MultiArch/2016.1/17297 (2016/02/03).

Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#4 16845 C. Thomas Tyler Fixed typo in script name in a comment; no functional change.
#3 15856 C. Thomas Tyler Replaced the big license comment block with a shortened
form referencing the LICENSE file included with the SDP
package, and also by the URL for the license file in
The Workshop.
#2 15777 C. Thomas Tyler No functional changes.

Style Policing only on bash scripts only.

Normalized indentation and line breaks, removed offending tabs, and general whitespace
usage.
#1 15716 Russell C. Jackson (Rusty) Script for rebuilding an Edge server.