#!/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 weekly_backup.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 | |
---|---|---|---|---|---|
#1 | 19278 | trina | "Forking branch Main of perforce-software-sdp to trina-sdp." | ||
//guest/perforce_software/sdp/main/Server/Unix/p4/common/bin/recover_edge.sh | |||||
#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. |