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 while [ -n "$1" ]; do
case "$1" in 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;; *) shift 1;;
esac esac
done done
@ -29,10 +31,13 @@ do_nothing() {
do_primary() { do_primary() {
echo "We are the primary. Creating package to send to secondary." echo "We are the primary. Creating package to send to secondary."
./rsync_xi.sh --prepend sync --secondary "$secondary"
} }
do_secondary() { do_secondary() {
echo "We are the secondary. Expanding package from the primary." 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 case "$hostname" in

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

Loading…
Cancel
Save