#!/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 recreates offline_db files from the latest checkpoint. If it fails, then # check to see if the most recent checkpoint in the /p4/INSTANCe/checkpoints directory is # bad (ie doesn't look like the right size compared to the others), and if so, delete it # and rerun this script. If the error you are getting is that the journal replay failed, # then the only option is to run live_checkpoint.sh script. # # This script can be called directly specifying instance, or using the p4master_run script # in order to properly set the environment variables for the script to reference. It # sources /p4/common/bin/p4_vars to set the environment variables that this script # depends on. # # This script is using the following external variables: # # SDP_INSTANCE - The instance of Perforce that is being backed up. Always an # integer value. # # 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 # We put the date directly on this file because we don't call rotate_last_run_logs in this # script since it is normally a one off run script. The regular backup scripts will maintain # the specified number of these logs per the $KEEPLOGS variable in p4_vars. LOGFILE=$LOGS/recreate_offline_db.log.$(date +'%Y:%m:%d-%H:%M:%S') ######### Start of Script ########## check_vars set_vars check_uid check_dirs ckp_running get_journalnum # Drop the journal number by one since we are not truncating the journal and # replay_journals_to_offline_db assumes a truncate_journal has been run. JOURNALNUM=$(($JOURNALNUM-1)) log "Start $P4SERVER recreate of offline db" recreate_offline_db_files log "Offline db basic recovery completed" /p4/common/bin/p4login get_offline_journal_num replay_journals_to_offline_db log "End $P4SERVER recreate offline db" mail_log_file "$HOSTNAME $P4SERVER recreate offline db log." ckp_complete
# | 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/recreate_offline_db.sh | |||||
#1 | 18619 | Russell C. Jackson (Rusty) | Updating main with current changes. | ||
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/recreate_offline_db.sh | |||||
#2 | 18587 | Russell C. Jackson (Rusty) |
Reworked the log rotation stuff in backup_functions.sh to make it cleaner and handle the new log from recreate_offline_db.sh. Modified recreate_offline_db.sh to add comments about a bad checkpoint. Also made it create its own log file since it isn't doing a checkpoint. Removed the log rotation for the same reason. Moved the LOGFILE setting out to all of scripts to make it more obvious for future scripts that you need to set that variable in your script so that it doesn't just default to checkpoint.log. Moved the functions in weekly_backup.sh and recreate_offline_db.sh into backup_functions.sh where they belong for consistency. Modified backup_functions.sh to use a consistent naming convention for all the rotated log files rather than checkpoint.log being unique. Replaced all back ticks with the newer bash $() method. Removed all of the line wrapping since I am pretty sure that none of us are working on an 80 character terminal these days and it is easier to read this way. |
||
#1 | 18534 | Robert Cowham |
New script to recreate_offline_db files from latest found checkpoint. Something to try before live_checkpoint (which blocks live database). |