Ready to test secondary

2021
Eric Loyd 6 years ago
parent 42cb02e387
commit d322efa083

@ -15,7 +15,9 @@ hostname=`/bin/hostname`
while [ -n "$1" ]; do
case "$1" in
-H) hostname="$2"; shift 2;;
-H | --hostname) hostname="$2"; shift 2;;
-s | --secondary) secondary="$2"; shift 2;;
-p | --primary) primary="$2"; shift 2;;
*) shift 1;;
esac
done
@ -29,10 +31,13 @@ do_nothing() {
do_primary() {
echo "We are the primary. Creating package to send to secondary."
./rsync_xi.sh --prepend sync --secondary "$secondary"
}
do_secondary() {
echo "We are the secondary. Expanding package from the primary."
mysqlfile=`ls -tr1 /store/backups/nagiosxi/ | tail -1`
[ -z "$mysqlfile" ] && echo "No MySQL Backup file." && exit 2
}
case "$hostname" in

@ -4,10 +4,11 @@
# Copyright (c) 2011-2018 Nagios Enterprises, LLC. All rights reserved.
#
BASEDIR=$(dirname $(readlink -f $0))
BASEDIR=/usr/local/nagiosxi/scripts
# FIXME
SBLOG="/usr/local/nagiosxi/var/components/scheduledbackups.log"
ts=`date +%s`
secondary=""
# Import Nagios XI and xi-sys.cfg config vars
. $BASEDIR/../var/xi-sys.cfg
@ -32,6 +33,9 @@ usage () {
###############################
while [ -n "$1" ]; do
case "$1" in
-s | --secondary)
secondary="$2"
;;
-h | --help)
usage
exit 0
@ -52,7 +56,10 @@ while [ -n "$1" ]; do
shift
done
[ -z "$secondary" ] && echo "Secondary not specified." && exit 2
# Restart nagios to forcibly update retention.dat
echo "Restart nagios to forcibly update retention.dat"
$BASEDIR/manage_services.sh restart nagios
sleep 10
@ -88,9 +95,12 @@ mkdir -p $mydir
##############################
rsync_opts="-avun --delete --delete-after"
do_rsync() {
echo rsync $rsync_opts $1 secondary:${1}
echo rsync -avun --delete --delete-after $1 ${secondary}:${1}
}
do_rsync2() {
rsync -avu --delete --delete-after $1 ${secondary}:${1}
}
# Only backup NagiosQL if it exists
@ -244,14 +254,11 @@ rm -rf $name
chown $nagiosuser:$nagiosgroup $name.tar.gz
if [ -s $name.tar.gz ];then
echo " "
echo "==============="
echo "BACKUP COMPLETE"
echo "==============="
echo "Backup stored in $rootdir/$name.tar.gz"
exit 0;
else
echo " "
echo "==============="
@ -261,3 +268,5 @@ else
rm -r $mydir
exit 1;
fi
do_rsync2 $rootdir/$name.tar.gz

Loading…
Cancel
Save