#!/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 | |
|---|---|---|---|---|---|
| #5 | 23430 | Robert Cowham | Merge in changes from dev | ||
| #4 | 23205 | Robert Cowham | Merged all changes from dev to test | ||
| #3 | 22142 | Robert Cowham | Merge in latest changes from Dev | ||
| #2 | 20726 | Robert Cowham | Catch up from dev | ||
| #1 | 18586 | Robert Cowham | Branching using cowhamr.sdp.dev | ||
| //guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/recover_edge.sh | |||||
| #5 | 17293 | Robert Cowham | Clarifications in comments - no functional change. | ||
| #4 | 17219 | C. Thomas Tyler | Routine Merge Down to dev from main. | ||
| #3 | 16029 | C. Thomas Tyler |
Routine merge to dev from main using: p4 merge -b perforce_software-sdp-dev |
||
| #2 | 15778 | C. Thomas Tyler | Routine Merge Down to dev from main. | ||
| #1 | 15753 | C. Thomas Tyler | Routine Merge Down to dev from main. | ||
| //guest/perforce_software/sdp/main/Server/Unix/p4/common/bin/recover_edge.sh | |||||
| #1 | 15716 | Russell C. Jackson (Rusty) | Script for rebuilding an Edge server. | ||