First stage of failovers

2021
Eric Loyd 6 years ago
parent cfb349887f
commit 42cb02e387

@ -0,0 +1,42 @@
#!/bin/sh
#
# Nagios XI failover for Princeton University
#
# Initial version written by:
# Eric Loyd (eloyd@everwatch.global)
# EverWatch Global, Inc.
PATH=/usr/sbin:/sbin:/usr/bin:/bin
primary="nagiosxi-p.princeton.edu"
secondary="nagiosxi-f.princeton.edu"
hostname=`/bin/hostname`
while [ -n "$1" ]; do
case "$1" in
-H) hostname="$2"; shift 2;;
*) shift 1;;
esac
done
[ -z "$hostname" ] && echo "Invalid hostname." && exit 2
do_nothing() {
echo "We are not the primary or secondary. Doing nothing."
exit
}
do_primary() {
echo "We are the primary. Creating package to send to secondary."
}
do_secondary() {
echo "We are the secondary. Expanding package from the primary."
}
case "$hostname" in
$primary) do_primary;;
$secondary) do_secondary;;
*) do_nothing
esac

@ -0,0 +1,422 @@
#!/bin/bash
#
# Restores a Full Backup of Nagios XI
# Copyright (c) 2008-2018 Nagios Enterprises, LLC. All rights reserved.
#
# Change this password if your root password is different than "nagiosxi"
# MySQL root password
themysqlpass="nagiosxi"
# Make sure we have the backup file
if [ $# != 1 ]; then
echo "Usage: $0 <backupfile>"
echo "This script restores your XI system using a previously made Nagios XI backup file."
exit 1
fi
backupfile=$1
BASEDIR=/usr/local/nagiosxi/scripts
SPECIAL_BACKUP=0
# Import Nagios XI and xi-sys.cfg config vars
. $BASEDIR/../var/xi-sys.cfg
eval $(php $BASEDIR/import_xiconfig.php)
# Must be root
me=`whoami`
if [ $me != "root" ]; then
echo "You must be root to run this script."
exit 1
fi
rootdir=/store/backups/nagiosxi
##############################
# MAKE SURE BACKUP FILE EXIST
##############################
if [ ! -f $backupfile ]; then
echo "Unable to find backup file $backupfile!"
exit 1
fi
# Restore just needs to restore the MySQL stuff. Everything else was shipped over via rsync
## Look inside the (nested) tarball to see what architecture the nagios
## executable is
#if [ $backupfile == "/store/backups/nagiosxi-demo.tar.gz" ];then
#backuparch="x86_64"
#else
#backuparch=$(eval $(echo $(tar -xzOf $backupfile $(basename $backupfile .tar.gz)/nagiosxi.tar.gz | tar -xzOf - usr/local/nagiosxi/var/xi-sys.cfg |cat|grep ^arch\=));echo $arch)
#
#fi
#arch=$(uname -m)
#case $arch in
# i*86 ) arch="i686" ;;
# x86_64 ) arch="x86_64" ;;
# * ) echo "Error detecting architecture."; exit 1
#esac
#
#if [ "$arch" != "$backuparch" ]; then
# echo "WARNING: you are trying to restore a $backuparch backup on a $arch system"
# echo " Compiled plugins and other binaries will NOT be restored."
# echo
# read -r -p "Are you sure you want to continue? [y/N] " ok
#
# case "$ok" in
# Y | y ) : ;;
# * ) exit 1
# esac
#fi
#
#backupdist=$(eval $(echo $(tar -xzOf $backupfile $(basename $backupfile .tar.gz)/nagiosxi.tar.gz | tar -xzOf - usr/local/nagiosxi/var/xi-sys.cfg |cat|grep ^dist\=));echo $dist)
#
#if [ "$dist" != "$backupdist" ]; then
# SPECIAL_BACKUP=1
#
# echo "WARNING: you are trying to restore a $backupdist backup on a $dist system"
# echo " Compiled plugins and other binaries as well as httpd configurations"
# echo " will NOT be restored."
# echo ""
# echo " You will need to re-download the Nagios XI tarball, and re-install"
# echo " the subcomponents for this system. More info here:"
# echo " https://assets.nagios.com/downloads/nagiosxi/docs/Backing-Up-And-Restoring-Nagios-XI.pdf"
# echo ""
# read -r -p "Are you sure you want to continue? [y/N] " ok
#
# case "$ok" in
# Y | y ) : ;;
# * ) exit 1
# esac
#fi
##############################
# MAKE TEMP RESTORE DIRECTORY
##############################
#ts=`echo $backupfile | cut -d . -f 1`
ts=`date +%s`
echo "TS=$ts"
mydir=${rootdir}/${ts}-restore
mkdir -p $mydir
if [ ! -d $mydir ]; then
echo "Unable to create restore directory $mydir!"
exit 1
fi
##############################
# UNZIP BACKUP
##############################
echo "Extracting backup to $mydir..."
cd $mydir
tar xzfps $backupfile
# Change to subdirectory
cd `ls`
# Make sure we have some directories here...
backupdir=`pwd`
echo "In $backupdir..."
#if [ ! -f nagiosxi.tar.gz ]; then
# echo "Unable to find files to restore in $backupdir"
# exit 1
#fi
echo "Backup files look okay. Preparing to restore..."
##############################
# SHUTDOWN SERVICES
##############################
echo "Shutting down services..."
$BASEDIR/manage_services.sh stop nagios
$BASEDIR/manage_services.sh stop ndo2db
$BASEDIR/manage_services.sh stop npcd
##############################
# RESTORE DIRS
##############################
rootdir=/
#echo "Restoring directories to ${rootdir}..."
#
## Nagios Core
#echo "Restoring Nagios Core..."
#if [ "$arch" == "$backuparch" ] && [ $SPECIAL_BACKUP -eq 0 ]; then
# rm -rf /usr/local/nagios
# cd $rootdir && tar xzf $backupdir/nagios.tar.gz
#else
# rm -rf /usr/local/nagios/etc /usr/local/nagios/share /usr/local/nagios/var
# cd $rootdir && tar --exclude="usr/local/nagios/bin" --exclude="usr/local/nagios/sbin" --exclude="usr/local/nagios/libexec" -xzf $backupdir/nagios.tar.gz
# cd $rootdir && tar --wildcards 'usr/local/nagios/libexec/*.*' -xzf $backupdir/nagios.tar.gz
#fi
#
## Restore ramdisk if it exists
#if [ -f "$backupdir/ramdisk.nagios" ]; then
# echo "Updating ramdisk configuration..."
# cp $backupdir/ramdisk.nagios /etc/sysconfig/nagios
#fi
#
## Nagios XI
#echo "Restoring Nagios XI..."
#if [ "$arch" == "$backuparch" ] && [ $SPECIAL_BACKUP -eq 0 ]; then
# rm -rf /usr/local/nagiosxi
# cd $rootdir && tar xzfps $backupdir/nagiosxi.tar.gz
#else
# mv $BASEDIR/../var/xi-sys.cfg /tmp/xi-sys.cfg
# mv $BASEDIR/../var/certs /tmp/certs
# mv $BASEDIR/../var/keys /tmp/keys
#
# rm -rf /usr/local/nagiosxi
# cd $rootdir && tar xzfps $backupdir/nagiosxi.tar.gz
#
# cp -r /tmp/xi-sys.cfg $BASEDIR/../var/xi-sys.cfg
# rm -f /tmp/xi-sys.cfg
#
# # Check for certs
# mkdir -p $BASEDIR/../var/certs
# cp -r /tmp/certs $BASEDIR/../var/
#
# rm -rf /tmp/certs
#
# # Check for keys
# mkdir -p $BASEDIR/../var/keys
# cp -r /tmp/keys $BASEDIR/../var/
#
# rm -rf /tmp/keys
#fi
#
## NagiosQL
#if [ -d "/var/www/html/nagiosql" ]; then
#
# echo "Restoring NagiosQL..."
# rm -rf /var/www/html/nagiosql
# cd $rootdir && tar xzfps $backupdir/nagiosql.tar.gz
#
# # NagiosQL etc
# echo "Restoring NagiosQL backups..."
# rm -rf /etc/nagiosql
# cd $rootdir && tar xzfps $backupdir/nagiosql-etc.tar.gz
#
#fi
#
## NRDP
#echo "Restoring NRDP backups..."
#rm -rf /usr/local/nrdp
#cd $rootdir && tar xzfps $backupdir/nrdp.tar.gz
#
## MRTG
#if [ -f $backupdir/mrtg.tar.gz ]; then
# echo "Restoring MRTG..."
# rm -rf /var/lib/mrtg
# cd $rootdir && tar xzfps $backupdir/mrtg.tar.gz
# cp -rp $backupdir/conf.d /etc/mrtg/
# cp -p $backupdir/mrtg.cfg /etc/mrtg/
# chown $apacheuser:$nagiosgroup /etc/mrtg/conf.d /etc/mrtg/mrtg.cfg
#fi
#cd $backupdir
#
## SNMP configs and MIBS
#if [ -f $backupdir/etc-snmp.tar.gz ]; then
# echo "Restoring SNMP configuration files..."
# cd $rootdir && tar xzfps $backupdir/etc-snmp.tar.gz
#fi
#if [ -f $backupdir/usr-share-snmp.tar.gz ]; then
# echo "Restoring SNMP MIBs..."
# cd $rootdir && tar xzfps $backupdir/usr-share-snmp.tar.gz
#fi
#
# Nagvis
#if [ -f $backupdir/nagvis.tar.gz ]; then
# echo "Restoring Nagvis backups..."
# rm -rf /usr/local/nagvis
# cd $rootdir && tar xzfps $backupdir/nagvis.tar.gz
# chown -R $apacheuser:$nagiosgroup /usr/local/nagvis
#fi
#
## nagios user home
#if [ -f $backupdir/home-nagios.tar.gz ]; then
# echo "Restoring nagios home dir..."
# cd $rootdir && tar xzfps $backupdir/home-nagios.tar.gz
#fi
# RE-IMPORT ALL XI CFG VARS
. $BASEDIR/../var/xi-sys.cfg
php $BASEDIR/import_xiconfig.php > $BASEDIR/config.dat
. $BASEDIR/config.dat
rm -rf $BASEDIR/config.dat
# Overwrite the mysqlpass with the hardcoded one at the top
mysqlpass="$themysqlpass"
##############################
# RESTORE DATABASES
##############################
echo "Restoring MySQL databases..."
if [[ "$cfg__db_info__ndoutils__dbserver" == *":"* ]]; then
ndoutils_dbport=`echo "$cfg__db_info__ndoutils__dbserver" | cut -f2 -d":"`
ndoutils_dbserver=`echo "$cfg__db_info__ndoutils__dbserver" | cut -f1 -d":"`
else
ndoutils_dbport='3306'
ndoutils_dbserver="$cfg__db_info__ndoutils__dbserver"
fi
mysql -h "$ndoutils_dbserver" --port="$ndoutils_dbport" -u root --password=$mysqlpass < $backupdir/mysql/nagios.sql
res=$?
if [ $res != 0 ]; then
echo "Error restoring MySQL database 'nagios' - check the password in this script!"
exit;
fi
if [[ "$cfg__db_info__nagiosql__dbserver" == *":"* ]]; then
nagiosql_dbport=`echo "$cfg__db_info__nagiosql__dbserver" | cut -f2 -d":"`
nagiosql_dbserver=`echo "$cfg__db_info__nagiosql__dbserver" | cut -f1 -d":"`
else
nagiosql_dbport='3306'
nagiosql_dbserver="$cfg__db_info__nagiosql__dbserver"
fi
mysql -h "$nagiosql_dbserver" --port="$nagiosql_dbport" -u root --password=$mysqlpass < $backupdir/mysql/nagiosql.sql
res=$?
if [ $res != 0 ]; then
echo "Error restoring MySQL database 'nagiosql' - check the password in this script!"
exit;
fi
# Only restore PostgresQL if we are still using it
if [ "$cfg__db_info__nagiosxi__dbtype" == "pgsql" ]; then
service postgresql initdb &>/dev/null || true
echo "Restoring Nagios XI PostgresQL database..."
if [ -f /var/lib/pgsql/data/pg_hba.conf ]; then
pghba="/var/lib/pgsql/data/pg_hba.conf"
cp -pr $pghba $pghba.old
else
#Ubuntu/Debian
pghba=$(find /etc/postgresql -name "*pg_hba.conf")
cp -pr $pghba $pghba.old
fi
echo "local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust" > $pghba
$BASEDIR/manage_services.sh start postgresql
sudo -u postgres psql -c "create user nagiosxi with password 'n@gweb';"
sudo -u postgres psql -c "create database nagiosxi owner nagiosxi;"
$BASEDIR/manage_services.sh restart postgresql
# Sleep a bit (required so Postgres finishes startup before we connect again)
echo "Sleeping for a few seconds (please wait)..."
sleep 7
psql -U nagiosxi nagiosxi < $backupdir/pgsql/nagiosxi.sql
res=$?
if [ $res != 0 ]; then
echo "Error restoring PostgresQL database 'nagiosxi' !"
exit;
fi
$BASEDIR/manage_services.sh restart postgresql
if [ "$dist" == "el7" ] || [ "$dist" == "el8" ]; then
systemctl enable postgresql.service
elif [[ "$distro" == "Ubuntu" ]] || [[ "$distro" == "Debian" ]]; then
update-rc.d postgresql enable
else
chkconfig postgresql on
fi
# Remove nagiosxi db from mysql if postgres is used instead
if [[ "$cfg__db_info__nagiosql__dbserver" == *":"* ]]; then
nagiosql_dbport=`echo "$cfg__db_info__nagiosql__dbserver" | cut -f2 -d":"`
nagiosql_dbserver=`echo "$cfg__db_info__nagiosql__dbserver" | cut -f1 -d":"`
else
nagiosql_dbport='3306'
nagiosql_dbserver="$cfg__db_info__nagiosql__dbserver"
fi
mysql -h "$nagiosql_dbserver" --port="$nagiosql_dbport" -u root --password=$mysqlpass < "DROP TABLE IF EXISTS nagiosxi;"
else
echo "Restoring Nagios XI MySQL database..."
if [[ "$cfg__db_info__nagiosxi__dbserver" == *":"* ]]; then
nagiosxi_dbport=`echo "$cfg__db_info__nagiosxi__dbserver" | cut -f2 -d":"`
nagiosxi_dbserver=`echo "$cfg__db_info__nagiosxi__dbserver" | cut -f1 -d":"`
else
nagiosxi_dbport='3306'
if [ "x$cfg__db_info__nagiosxi__dbserver" == "x" ]; then
nagiosxi_dbserver="localhost"
else
nagiosxi_dbserver="$cfg__db_info__nagiosxi__dbserver"
fi
fi
mysql -h "$nagiosxi_dbserver" --port="$nagiosxi_dbport" -u root --password=$mysqlpass < $backupdir/mysql/nagiosxi.sql
res=$?
if [ $res != 0 ]; then
echo "Error restoring MySQL database 'nagiosxi' !"
exit;
fi
fi
echo "Restarting database servers..."
$BASEDIR/manage_services.sh restart mysqld
###############################
## RESTORE CRONJOB ENTRIES
###############################
#echo "Restoring Apache cronjobs..."
#if [[ "$distro" == "Ubuntu" ]] || [[ "$distro" == "Debian" ]]; then
# cp $backupdir/cron/apache /var/spool/cron/crontabs/$apacheuser
#else
# cp $backupdir/cron/apache /var/spool/cron/apache
#fi
##############################
# RESTORE SUDOERS
##############################
# Not necessary
###############################
## RESTORE LOGROTATE
###############################
#echo "Restoring logrotate config files..."
#cp -rp $backupdir/logrotate/nagiosxi /etc/logrotate.d
###############################
## RESTORE APACHE CONFIG FILES
###############################
#if [ $SPECIAL_BACKUP -eq 0 ]; then
# echo "Restoring Apache config files..."
# cp -rp $backupdir/httpd/nagios.conf $httpdconfdir
# cp -rp $backupdir/httpd/nagiosxi.conf $httpdconfdir
# cp -rp $backupdir/httpd/nagiosmobile.conf $httpdconfdir
# cp -rp $backupdir/httpd/nagvis.conf $httpdconfdir
# cp -rp $backupdir/httpd/nrdp.conf $httpdconfdir
# if [ -d "/etc/apache2/sites-available" ]; then
# cp -rp $backupdir/httpd/default-ssl.conf /etc/apache2/sites-available
# else
# cp -rp $backupdir/httpd/ssl.conf $httpdconfdir
# fi
#else
# echo "Skipping Apache config files restoration"
#fi
##############################
# RESTART SERVICES
##############################
$BASEDIR/manage_services.sh restart httpd
$BASEDIR/manage_services.sh start npcd
$BASEDIR/manage_services.sh start ndo2db
$BASEDIR/manage_services.sh start nagios
##############################
# DELETE TEMP RESTORE DIRECTORY
##############################
rm -rf $mydir
##############################
# DELETE forceinstall FILE
##############################
rm -f /tmp/nagiosxi.forceinstall
echo " "
echo "==============="
echo "RESTORE COMPLETE"
echo "==============="
exit 0

@ -0,0 +1,263 @@
#!/bin/bash
#
# Creates a Full Backup of Nagios XI
# Copyright (c) 2011-2018 Nagios Enterprises, LLC. All rights reserved.
#
BASEDIR=$(dirname $(readlink -f $0))
BASEDIR=/usr/local/nagiosxi/scripts
SBLOG="/usr/local/nagiosxi/var/components/scheduledbackups.log"
ts=`date +%s`
# Import Nagios XI and xi-sys.cfg config vars
. $BASEDIR/../var/xi-sys.cfg
eval $(php $BASEDIR/import_xiconfig.php)
###############################
# USAGE / HELP
###############################
usage () {
echo ""
echo "Use this script to backup Nagios XI."
echo ""
echo " -n | --name Set the name of the backup minus the .tar.gz"
echo " -p | --prepend Prepend 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 ""
}
###############################
# ADDING LOGIC FOR NEW BACKUPS
###############################
while [ -n "$1" ]; do
case "$1" in
-h | --help)
usage
exit 0
;;
-n | --name)
fullname=$2
;;
-p | --prepend)
prepend=$2"."
;;
-a | --append)
append="."$2
;;
-d | --directory)
rootdir=$2
;;
esac
shift
done
# Restart nagios to forcibly update retention.dat
$BASEDIR/manage_services.sh restart nagios
sleep 10
if [ -z $rootdir ]; then
rootdir="/store/backups/nagiosxi"
fi
# Move to root dir to store backups
cd $rootdir
#############################
# SET THE NAME & TIME
#############################
name=$fullname
if [ -z $fullname ]; then
name=$prepend$ts$append
fi
# Get current Unix timestamp as name
if [ -z $name ]; then
name=$ts
fi
# My working directory
mydir=$rootdir/$name
# Make directory for this specific backup
mkdir -p $mydir
##############################
# BACKUP DIRS
##############################
rsync_opts="-avun --delete --delete-after"
do_rsync() {
echo rsync $rsync_opts $1 secondary:${1}
}
# Only backup NagiosQL if it exists
if [ -d "/var/www/html/nagiosql" ]; then
echo "Backing up NagiosQL..."
do_rsync /var/www/html/nagiosql
do_rsync /etc/nagiosql
fi
echo "Backing up Nagios Core..."
do_rsync /usr/local/nagios
# Backup ramdisk if it exists
if [ -f "/etc/sysconfig/nagios" ]; then
echo "Copying ramdisk configuration..."
do_rsync /etc/sysconfig/nagios
fi
echo "Backing up Nagios XI..."
do_rsync /usr/local/nagiosxi
echo "Backing up MRTG..."
do_rsync /var/lib/mrtg
do_rsync /etc/mrtg/mrtg.cfg
do_rsync /etc/mrtg/conf.d
# SNMP configs and MIBS
echo "Backing up the SNMP directories"
do_rsync /etc/snmp
do_rsync /usr/share/snmp
echo "Backing up NRDP..."
do_rsync /usr/local/nrdp
echo "Backing up Nagvis..."
do_rsync /usr/local/nagvis
echo "Backing up nagios user home dir..."
do_rsync /home/nagios
##############################
# BACKUP DATABASES
##############################
echo "Backing up MySQL databases..."
mkdir -p $mydir/mysql
if [[ "$cfg__db_info__ndoutils__dbserver" == *":"* ]]; then
ndoutils_dbport=`echo "$cfg__db_info__ndoutils__dbserver" | cut -f2 -d":"`
ndoutils_dbserver=`echo "$cfg__db_info__ndoutils__dbserver" | cut -f1 -d":"`
else
ndoutils_dbport='3306'
ndoutils_dbserver="$cfg__db_info__ndoutils__dbserver"
fi
mysqldump -h "$ndoutils_dbserver" --port="$ndoutils_dbport" -u $cfg__db_info__ndoutils__user --password="$cfg__db_info__ndoutils__pwd" --add-drop-database -B $cfg__db_info__ndoutils__db > $mydir/mysql/nagios.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up MySQL database 'nagios' - check the password in this script!" | tee -a $SBLOG
rm -r $mydir
exit $res;
fi
if [[ "$cfg__db_info__nagiosql__dbserver" == *":"* ]]; then
nagiosql_dbport=`echo "$cfg__db_info__nagiosql__dbserver" | cut -f2 -d":"`
nagiosql_dbserver=`echo "$cfg__db_info__nagiosql__dbserver" | cut -f1 -d":"`
else
nagiosql_dbport='3306'
nagiosql_dbserver="$cfg__db_info__nagiosql__dbserver"
fi
mysqldump -h "$nagiosql_dbserver" --port="$nagiosql_dbport" -u $cfg__db_info__nagiosql__user --password="$cfg__db_info__nagiosql__pwd" --add-drop-database -B $cfg__db_info__nagiosql__db > $mydir/mysql/nagiosql.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up MySQL database 'nagiosql' - check the password in this script!" | tee -a $SBLOG
rm -r $mydir
exit $res;
fi
# Only backup PostgresQL if we are still using it
if [ $cfg__db_info__nagiosxi__dbtype == "pgsql" ]; then
echo "Backing up PostgresQL databases..."
mkdir -p $mydir/pgsql
if [ -z $cfg__db_info__nagiosxi__dbserver ]; then
cfg__db_info__nagiosxi__dbserver="localhost"
fi
pg_dump -h $cfg__db_info__nagiosxi__dbserver -c -U $cfg__db_info__nagiosxi__user $cfg__db_info__nagiosxi__db > $mydir/pgsql/nagiosxi.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up PostgresQL database 'nagiosxi' !" | tee -a $SBLOG
rm -r $mydir
exit $res;
fi
else
if [[ "$cfg__db_info__nagiosxi__dbserver" == *":"* ]]; then
nagiosxi_dbport=`echo "$cfg__db_info__nagiosxi__dbserver" | cut -f2 -d":"`
nagiosxi_dbserver=`echo "$cfg__db_info__nagiosxi__dbserver" | cut -f1 -d":"`
else
nagiosxi_dbport='3306'
nagiosxi_dbserver="$cfg__db_info__nagiosxi__dbserver"
fi
mysqldump -h "$nagiosxi_dbserver" --port="$nagiosxi_dbport" -u $cfg__db_info__nagiosxi__user --password="$cfg__db_info__nagiosxi__pwd" --add-drop-database -B $cfg__db_info__nagiosxi__db > $mydir/mysql/nagiosxi.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up MySQL database 'nagiosxi' - check the password in this script!" | tee -a $SBLOG
rm -r $mydir
exit $res;
fi
fi
##############################
# BACKUP CRONJOB ENTRIES
##############################
echo "Backing up cronjobs for Apache..."
if [[ "$distro" == "Ubuntu" ]] || [[ "$distro" == "Debian" ]]; then
do_rsync /var/spool/cron/crontabs/$apacheuser
else
do_rsync /var/spool/cron/apache
fi
##############################
# BACKUP SUDOERS
##############################
# Not necessary
##############################
# BACKUP LOGROTATE
##############################
echo "Backing up logrotate config files..."
do_rsync /etc/logrotate.d/nagiosxi
##############################
# BACKUP APACHE CONFIG FILES
##############################
echo "Backing up Apache config files..."
do_rsync $httpdconfdir/nagios.conf
do_rsync $httpdconfdir/nagiosxi.conf
do_rsync $httpdconfdir/nagiosmobile.conf
do_rsync $httpdconfdir/nagvis.conf
do_rsync $httpdconfdir/nrdp.conf
if [ -d "/etc/apache2/sites-available" ]; then
do_rsync /etc/apache2/sites-available/default-ssl.conf
else
do_rsync $httpdconfdir/ssl.conf
fi
##############################
# COMPRESS BACKUP
##############################
echo "Compressing backup..."
tar czfp $name.tar.gz $name
rm -rf $name
# Change ownership
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 "==============="
echo "BACKUP FAILED"
echo "==============="
echo "File was not created at $rootdir/$name.tar.gz"
rm -r $mydir
exit 1;
fi
Loading…
Cancel
Save