failover.sh can now request that rsync continue without syncing, just to activate Nagios

release-2.6.13^2
Eric Loyd 4 years ago
parent 90bf02cbc4
commit 3e0c08db72

@ -90,8 +90,19 @@ do_secondary() {
fi fi
verbose "Expanding package from the primary" verbose "Expanding package from the primary"
syncfile=$(basename `ls -tr1 ${backupDir}/${syncname}* | tail -1`) syncfile=$(basename `ls -tr1 ${backupDir}/${syncname}* | tail -1`)
[ -z "$syncfile" ] && error "No sync file ($syncfile) found." && exit 2 if [ -z "$syncfile" ]; then
error "No sync file ($syncfile) found."
warning "Continue anyway? (10 second timeout, one letter only please) [y/N] " -n
read -t 10 -e -n 1 continueAnyway
if [ "$continueAnyway" = "y" -o "$continueAnyway" = "Y" ]; then
/home/nagios/bin/rsync_xi.sh --primary "${primary}" --secondary "${secondary}" --file "/store/backups/nagiosxi/$syncfile" --nofile
else
verbose "Exiting."
exit 2
fi
else
/home/nagios/bin/rsync_xi.sh --primary "${primary}" --secondary "${secondary}" --file "/store/backups/nagiosxi/$syncfile" /home/nagios/bin/rsync_xi.sh --primary "${primary}" --secondary "${secondary}" --file "/store/backups/nagiosxi/$syncfile"
fi
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
# Update header.css with proper gradient files # Update header.css with proper gradient files
if [ -r "${cssDir}/header.css.secondary" -a -w "${cssDir}/header.css" ]; then if [ -r "${cssDir}/header.css.secondary" -a -w "${cssDir}/header.css" ]; then

@ -14,6 +14,7 @@ hostname="`/bin/hostname`"
pName="" pName=""
sName="" sName=""
noping=/bin/false noping=/bin/false
noFile=/bin/false
execute="-n" execute="-n"
syncfile="" syncfile=""
isP=/bin/false isP=/bin/false
@ -38,6 +39,7 @@ usage () {
echo " -p | --prepend Prepend a string to the .tar.gz name" echo " -p | --prepend Prepend a string to the .tar.gz name"
echo " -a | --append Append a string to the .tar.gz name" echo " -a | --append Append a string to the .tar.gz name"
echo " -d | --directory Change the directory to store the compressed backup" echo " -d | --directory Change the directory to store the compressed backup"
echo " --nofile Ignore the missing sync file but continue the process"
echo "" echo ""
} }
@ -61,6 +63,9 @@ while [ -n "$1" ]; do
--noping) --noping)
noping=/bin/true noping=/bin/true
;; ;;
--nofile)
noFile=/bin/true
;;
-h | --help) -h | --help)
usage usage
exit 0 exit 0
@ -278,6 +283,8 @@ test_mysql_connection() {
rootdir=/store/backups/nagiosxi rootdir=/store/backups/nagiosxi
backupfile=$1 backupfile=$1
# This is a poor way to write this, but it's the easiest. Skip doing all the restore operations if there's no file to restore from.
if [ ! $noFile ]; then
if [ ! -f $backupfile ]; then if [ ! -f $backupfile ]; then
error "Unable to find backup file $backupfile!" error "Unable to find backup file $backupfile!"
exit 1 exit 1
@ -476,7 +483,7 @@ else
exit 1 exit 1
fi fi
fi fi
fi # This is from the "noFile" check previously
############################## ##############################
# RESTART SERVICES # RESTART SERVICES
############################## ##############################
@ -497,7 +504,7 @@ echo "==============="
} }
do_secondary() { do_secondary() {
[ ! -r "$syncfile" ] && error "No sync file ($syncfile) found." && exit 2 [ ! $noFile -a ! -r "$syncfile" ] && error "No sync file ($syncfile) found." && exit 2
restore_secondary "$syncfile" restore_secondary "$syncfile"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
rm -f ${syncfile} rm -f ${syncfile}

Loading…
Cancel
Save