rotate_journal.sh #6

  • //
  • guest/
  • russell_jackson/
  • sdp/
  • Server/
  • Unix/
  • p4/
  • common/
  • bin/
  • rotate_journal.sh
  • View
  • Commits
  • Open Download .zip Download (2 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 expects the most recent valid checkpoint to be available in
# $CHECKPOINTS in order for this script to work.
#
# This script is using the following external variables:
#
# SDP_INSTANCE - The instance of Perforce that is being backed up. If not
# set in environment, pass in as argument to script.
#
# P4HOME - Server's home directory.
# P4BIN - Command line client name for the instance being backed up.
# P4DBIN - Server executable name for the instance being backed up.
# P4ROOT - Server's root directory. p4/root, p4_N/root
# P4PORT - TCP/IP port for the server instance being backed up.
# P4JOURNAL - Location of the Journal for the server instance being backed up.
#
#
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 

. /p4/common/bin/p4_vars $SDP_INSTANCE
. /p4/common/bin/backup_functions.sh
LOGFILE=$LOGS/checkpoint.log

######### Start of Script ##########

check_vars
set_vars
get_journalnum
rotate_last_run_logs
log "Start $P4SERVER journal rotation"
check_uid
check_dirs
ckp_running
/p4/common/bin/p4login
truncate_journal
get_journalnum
get_offline_journal_num
replay_journals_to_offline_db
remove_old_checkpoints_and_journals
remove_old_logs
log "End $P4SERVER journal rotation"
ckp_complete

# Change User Description Committed
#6 25865 Russell C. Jackson (Rusty) Updated to work with changes to backup_functions.sh
#5 24858 Russell C. Jackson (Rusty) Set rpl.journalcopy.location=1 and removed all journals.rep references since it won't be needed anymore.
#4 22981 Russell C. Jackson (Rusty) Made files writeable so they are easier to update once on the server.
#3 22869 Russell C. Jackson (Rusty) Updated to only send email on error.
#2 22696 Russell C. Jackson (Rusty) Updates to support using journalnum in rotate_last_run_logs.
#1 22693 Russell C. Jackson (Rusty) Branched a Unix only version of the SDP.
Removed extra items to create a cleaner tree.
Moved a few items around to make more sense without Windows in the mix.
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/rotate_journal.sh
#5 20940 Russell C. Jackson (Rusty) Drop JOURNALNUM from the rotated log names because it forces you to wait to rotate
the prior logs until you get the journal number and creates a problem where the error
that you couldn't get the journal number ends up at the end of the previous days log
file, and that is what gets email out. That causes confusion for the person trying
to see what the error is.

Moved all rotate_last_run_logs up to the point right after we set the environment.
#4 20708 C. Thomas Tyler Per discussion: s/checkpoints.rep/journals.rep/g

This directory name changed, used in the journalPrefix configurable, is
intended to clarify that the should be targeted to for a FAST volume
for use with journalcopy, rather than the LARGE volume as would be
implied when using a directory with "checkpoints" in the name.
#3 20425 C. Thomas Tyler chmod +x rotate_journal.sh.

Done with: p4 edit -t +x rotate_journal.sh.

This is just a filetype tweak; there are no content changes.

#review-20426
#2 19768 UnstoppableDrew @tom_tyler @russell_jackson
Bug fix for running p4master_run as root, and some comment header cleanup. Job 000543

p4master_run: Preserve original arguments list and use this when exec'ing as $OSUSER.

backup_functions.sh: Add text about sourcing p4_vars yourself instead of using p4master_run.

update_limites.py: Run p4login directly without p4master_run since p4login calls p4_vars now.

everything else: Remove comment block about needing to run with p4master_run. Reword comment
  about SDP_INSTANCE since it is not always an integer value.
#1 18859 Russell C. Jackson (Rusty) Created script to rotate the journal and replay it to the offline database.

Updated the crontab to run the new script before the weekly.
Updated the edge crontab to account for the time adjustment in the master crontab.