|
|
|
|
@ -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
|
|
|
|
|
|