#!/bin/bash
#==============================================================================
# Copyright and license info is available in the LICENSE file included with
# the Server Deployment Package (SDP), and also available online:
# https://workshop.perforce.com/view/p4-sdp/main/LICENSE
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Version ID Block. Relies on +k filetype modifier.
# VersionID='$Id: //p4-sdp/r26.1.0/Server/Unix/p4/common/bin/keep_offline_db_current.sh#1 $ $Change: 33565 $'
# This script is for use only on a standby replica. It will not run on any
# other type of replica.
# This script ensures the offline_db has the most current journals replayed.
# It is intended for use on standby replicas as an alternative to sync_replica.sh
# or replica_cleanup.sh. It is ideal for use in an environment where the
# checkpoints folder of the P4TARGET server is shared (e.g. via NFS) with this
# server.
# This script does NOT do full checkpoint operations, and requires that the
# offline_db be in a good state before starting -- this is verified with
# a call to verify_sdp.sh.
# This uses checkpoint.log as its primary log. It is only intended for use
# on a machine where other scripts that update checkpoint.log don't run, e.g.
# daily_checkpoint.sh, live_checkpoint.sh, or rotate_journal.sh.
export SDP_INSTANCE=${SDP_INSTANCE:-Undefined}
export SDP_INSTANCE=${1:-$SDP_INSTANCE}
if [[ $SDP_INSTANCE == Undefined ]]; then
echo "Instance parameter not supplied."
echo "You must supply the Perforce instance as a parameter to this script."
exit 1
fi
# If environment variable is defined, then use that as default value if cli arguments not supplied
export P4SUPPRESSINFOEMAIL=${P4SUPPRESSINFOEMAIL:-false}
export P4SUPPRESSINFOEMAIL=${2:-$P4SUPPRESSINFOEMAIL}
# 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/checkpoint.log"
VerifyCmd="$P4CBIN/verify_sdp.sh $SDP_INSTANCE -skip ${VERIFY_SDP_SKIP_TEST_LIST:-},crontab,excess,init,license,masterid,version -L off"
######### Start of Script ##########
check_vars
set_vars
if [[ "$(is_standby "$SERVERID")" != YES ]]; then
die "Error: Run this only on a standby replica."
fi
rotate_last_run_logs
log "Start $P4SERVER Keep offline_db current"
log "Calling 'verify_sdp.sh' before replaying journal to offline_db:\\n$VerifyCmd"
$VerifyCmd >> "$LOGFILE" 2>&1 ||\
die "Error: Cannot confirm all is well with $P4CBIN/verify_sdp.sh. Aborting."
check_uid
check_dirs
check_offline_db_usable
ckp_running
get_journalnum
get_offline_journal_num
# Replay journals based on the P4TARGET server's journal prefix, which may
# or may not be NFS mounted, but is presumed to be current.
replay_journals_to_offline_db 1
# Remove old logs and journals based on the standby server's own journalPrefix,
# which will remove excess journals p4d has been rotating.
remove_old_checkpoints_and_journals
check_disk_space
remove_old_logs
log "End $P4SERVER Keep offline_db current"
if [[ "${P4SUPPRESSINFOEMAIL,,}" == "false" ]]; then
mail_log_file "$HOSTNAME $P4SERVER Daily maintenance log."
fi
ckp_complete
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #1 | 33565 | Claude (AI Agent by Anthropic) | Initial population of r26.1.0 from main. | ||
| //p4-sdp/main/Server/Unix/p4/common/bin/keep_offline_db_current.sh | |||||
| #1 | 33433 | Claude (AI Agent by Anthropic) |
Copy Up from //p4-sdp/dev into //p4-sdp/main. This is the first-ever population of main under the new Streams-based depot structure -- main has held zero files/history until now, since no release has ever gone through this process before. 463 files, covering the entire 2026.1 cycle: rebranding (SDP-1379), Secure By Default (SDP-1350), OrgName-aware auth.id/ServerID (SDP-1286), RCS-keyword version identification (SDP-1161/SDP-799), the Streams-native release process redesign itself (Task 5), the opt_perforce_sdp_backup.sh false-error fix, the P4D 2026.1 test-suite targeting, refreshed P4*.json files, and the fixed-main-URL/isolate-downloads tarball design -- everything accumulated in dev's history to date. Isolated paths (ai_dev_support/, Version, doc/*.html, doc/*.pdf, doc/gen/*.man.txt, doc/gen/sdp_install.cfg, Unsupported/doc/*.html, Unsupported/doc/*.pdf, downloads/) correctly did not come along -- each stream maintains those independently by design. Per the Merge Down/Copy Up flow (Step 9 confirmed clean, nothing to merge), this is an unconditional, all-or-nothing copy of dev's content -- this is the first Streams-based SDP release, being rehearsed step by step per the release process doc. Agent: Claude Code, Model: Claude Sonnet 5 (claude-sonnet-5), operating as bot_Claude_Anthropic. |
||
| //p4-sdp/dev/Server/Unix/p4/common/bin/keep_offline_db_current.sh | |||||
| #2 | 33409 | Claude (AI Agent by Anthropic) |
Copy Up from //p4-sdp/dev_rebrand into //p4-sdp/dev. This is the first promotion of dev_rebrand's work into dev since dev_rebrand was created (2025-05-24) -- 303 files, covering the entire 2026.1 rebranding effort (SDP-1379), the Secure By Default adaptation (SDP-1350), OrgName-aware auth.id/ServerID (SDP-1286), RCS-keyword version identification (SDP-1161/SDP-799), and the Streams-native release process redesign (Task 5) done this session, plus everything else accumulated in dev_rebrand's history before this session. Per the Merge Down/Copy Up flow, this is intentionally a full, unconditional blast-replace of dev's content from dev_rebrand -- all selectivity/care happened in the preceding Merge Down (dev -> dev_rebrand, changes 33407-33408), which absorbed Robert Cowham's independent dev-side work first so nothing of his is lost by this Copy Up. Two files are worth calling out since they might look alarming in isolation: - tools/mdcu.sh is deleted -- intentional, retired this session in favor of the two direct Streams commands now documented in doc/ReleaseProcessOverview.md. - tools/ReleaseProcessOverview.md is deleted -- this is a stale relic of a file move dev_rebrand made back in 2025-05-24 (tools/ -> doc/) that was never previously propagated to dev; the current, fully-rewritten doc/ReleaseProcessOverview.md is added/updated correctly by this same changelist. |
||
| #1 | 31397 | C. Thomas Tyler | Populate -b SDP_Classic_to_Streams -s //guest/perforce_software/sdp/...@31368. | ||
| //guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/keep_offline_db_current.sh | |||||
| #2 | 30663 | C. Thomas Tyler | Corrected log message in keep_offline_db_current.sh. | ||
| #1 | 29998 | C. Thomas Tyler |
Added new script to handle maintaining an offline_db on a standby replica that shares NFS with a commit server. #review-29999 |
||