|
|
|
@ -93,53 +93,49 @@ mkdir -p $mydir
|
|
|
|
##############################
|
|
|
|
##############################
|
|
|
|
# BACKUP DIRS
|
|
|
|
# BACKUP DIRS
|
|
|
|
##############################
|
|
|
|
##############################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do_rsync() {
|
|
|
|
do_rsync() {
|
|
|
|
rsync -avu --delete --delete-after $1 ${secondary}:${1}
|
|
|
|
echo "Syncing $*..."
|
|
|
|
|
|
|
|
rsync -av --delete --delete-after "$1" "${secondary}:${1}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Only backup NagiosQL if it exists
|
|
|
|
# Only backup NagiosQL if it exists
|
|
|
|
if [ -d "/var/www/html/nagiosql" ]; then
|
|
|
|
if [ -d "/var/www/html/nagiosql" ]; then
|
|
|
|
echo "Backing up NagiosQL..."
|
|
|
|
|
|
|
|
do_rsync /var/www/html/nagiosql/
|
|
|
|
do_rsync /var/www/html/nagiosql/
|
|
|
|
do_rsync /etc/nagiosql/
|
|
|
|
do_rsync /etc/nagiosql/
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo "Backing up Nagios Core..."
|
|
|
|
|
|
|
|
do_rsync /usr/local/nagios
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Backup ramdisk if it exists
|
|
|
|
# Backup ramdisk if it exists
|
|
|
|
if [ -f "/etc/sysconfig/nagios" ]; then
|
|
|
|
if [ -f "/etc/sysconfig/nagios" ]; then
|
|
|
|
echo "Copying ramdisk configuration..."
|
|
|
|
|
|
|
|
do_rsync /etc/sysconfig/nagios
|
|
|
|
do_rsync /etc/sysconfig/nagios
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$distro" == "Ubuntu" -o "$distro" == "Debian" ]; then
|
|
|
|
|
|
|
|
do_rsync /var/spool/cron/crontabs/$apacheuser
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
do_rsync /var/spool/cron/apache
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "/etc/apache2/sites-available" ]; then
|
|
|
|
|
|
|
|
do_rsync /etc/apache2/sites-available/default-ssl.conf
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
do_rsync $httpdconfdir/ssl.conf
|
|
|
|
|
|
|
|
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/
|
|
|
|
do_rsync /etc/mrtg/conf.d/
|
|
|
|
|
|
|
|
do_rsync /etc/mrtg/mrtg.cfg
|
|
|
|
# SNMP configs and MIBS
|
|
|
|
|
|
|
|
echo "Backing up the SNMP directories"
|
|
|
|
|
|
|
|
do_rsync /etc/snmp/
|
|
|
|
do_rsync /etc/snmp/
|
|
|
|
do_rsync /usr/share/snmp/
|
|
|
|
do_rsync /home/nagios/
|
|
|
|
|
|
|
|
do_rsync /usr/local/nagios/
|
|
|
|
echo "Backing up NRDP..."
|
|
|
|
do_rsync /usr/local/nagiosmobile/
|
|
|
|
do_rsync /usr/local/nrdp/
|
|
|
|
do_rsync /usr/local/nagiosxi/
|
|
|
|
|
|
|
|
|
|
|
|
echo "Backing up Nagvis..."
|
|
|
|
|
|
|
|
do_rsync /usr/local/nagvis/
|
|
|
|
do_rsync /usr/local/nagvis/
|
|
|
|
|
|
|
|
do_rsync /usr/local/nrdp/
|
|
|
|
|
|
|
|
do_rsync /usr/share/snmp/
|
|
|
|
|
|
|
|
do_rsync /var/lib/mrtg/
|
|
|
|
|
|
|
|
|
|
|
|
echo "Backing up nagios user home dir..."
|
|
|
|
do_rsync /etc/logrotate.d/nagiosxi
|
|
|
|
do_rsync /home/nagios/
|
|
|
|
do_rsync $httpdconfdir/nagiosxi.conf
|
|
|
|
|
|
|
|
do_rsync $httpdconfdir/nagiosmobile.conf
|
|
|
|
|
|
|
|
do_rsync $httpdconfdir/nagvis.conf
|
|
|
|
|
|
|
|
do_rsync $httpdconfdir/nrdp.conf
|
|
|
|
|
|
|
|
|
|
|
|
##############################
|
|
|
|
|
|
|
|
# BACKUP DATABASES
|
|
|
|
|
|
|
|
##############################
|
|
|
|
|
|
|
|
echo "Backing up MySQL databases..."
|
|
|
|
echo "Backing up MySQL databases..."
|
|
|
|
mkdir -p $mydir/mysql
|
|
|
|
mkdir -p $mydir/mysql
|
|
|
|
if [[ "$cfg__db_info__ndoutils__dbserver" == *":"* ]]; then
|
|
|
|
if [[ "$cfg__db_info__ndoutils__dbserver" == *":"* ]]; then
|
|
|
|
@ -170,7 +166,6 @@ if [ $res != 0 ]; then
|
|
|
|
rm -r $mydir
|
|
|
|
rm -r $mydir
|
|
|
|
exit $res;
|
|
|
|
exit $res;
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Only backup PostgresQL if we are still using it
|
|
|
|
# Only backup PostgresQL if we are still using it
|
|
|
|
if [ $cfg__db_info__nagiosxi__dbtype == "pgsql" ]; then
|
|
|
|
if [ $cfg__db_info__nagiosxi__dbtype == "pgsql" ]; then
|
|
|
|
echo "Backing up PostgresQL databases..."
|
|
|
|
echo "Backing up PostgresQL databases..."
|
|
|
|
@ -202,43 +197,6 @@ else
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
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
|
|
|
|
# COMPRESS BACKUP
|
|
|
|
##############################
|
|
|
|
##############################
|
|
|
|
|