|
|
|
@ -14,11 +14,11 @@ hostname="`/bin/hostname`"
|
|
|
|
pName=""
|
|
|
|
pName=""
|
|
|
|
sName=""
|
|
|
|
sName=""
|
|
|
|
noping=/bin/false
|
|
|
|
noping=/bin/false
|
|
|
|
noFile=/bin/false
|
|
|
|
|
|
|
|
execute="-n"
|
|
|
|
execute="-n"
|
|
|
|
syncfile=""
|
|
|
|
syncfile=""
|
|
|
|
isP=/bin/false
|
|
|
|
isP=/bin/false
|
|
|
|
isS=/bin/false
|
|
|
|
isS=/bin/false
|
|
|
|
|
|
|
|
rsync_opts="-a --delete --delete-after"
|
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
@ -39,7 +39,6 @@ usage () {
|
|
|
|
echo " -p | --prepend Prepend a string to the .tar.gz name"
|
|
|
|
echo " -p | --prepend Prepend a string to the .tar.gz name"
|
|
|
|
echo " -a | --append Append 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 " -d | --directory Change the directory to store the compressed backup"
|
|
|
|
echo " --nofile Ignore the missing sync file but continue the process"
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -63,9 +62,6 @@ while [ -n "$1" ]; do
|
|
|
|
--noping)
|
|
|
|
--noping)
|
|
|
|
noping=/bin/true
|
|
|
|
noping=/bin/true
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
--nofile)
|
|
|
|
|
|
|
|
noFile=/bin/true
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
-h | --help)
|
|
|
|
-h | --help)
|
|
|
|
usage
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
exit 0
|
|
|
|
@ -122,11 +118,12 @@ workDir=$rootdir/$name
|
|
|
|
mkdir -p $workDir
|
|
|
|
mkdir -p $workDir
|
|
|
|
|
|
|
|
|
|
|
|
do_rsync() {
|
|
|
|
do_rsync() {
|
|
|
|
verbose "Syncing $*..."
|
|
|
|
verbose "Syncing $1 (Excluding ${2:-nothing})..."
|
|
|
|
src="$1"
|
|
|
|
src="$1"
|
|
|
|
|
|
|
|
[ -n "$2" ] && exclude="--exclude $2" || exclude=""
|
|
|
|
[ ! -e "$src" ] && warning " OK: No such file or directory: $src" && return
|
|
|
|
[ ! -e "$src" ] && warning " OK: No such file or directory: $src" && return
|
|
|
|
[ -d "$src" ] && sudo rsync -a --delete --delete-after --rsync-path="sudo /bin/rsync" ${execute} ${src}/ nagios@${sName}:${src}/
|
|
|
|
[ -d "$src" ] && sudo /usr/bin/rsync --rsync-path="sudo /bin/rsync" ${rsync_opts} ${exclude} ${execute} ${src}/ nagios@${sName}:${src}/
|
|
|
|
[ -f "$src" ] && sudo rsync -a --delete --delete-after --rsync-path="sudo /bin/rsync" ${execute} ${src} nagios@${sName}:${src}
|
|
|
|
[ -f "$src" ] && sudo /usr/bin/rsync --rsync-path="sudo /bin/rsync" ${rsync_opts} ${exclude} ${execute} ${src} nagios@${sName}:${src}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
do_backup_files() {
|
|
|
|
do_backup_files() {
|
|
|
|
@ -155,7 +152,7 @@ do_rsync $httpdconfdir/nrdp.conf
|
|
|
|
do_rsync $httpdconfdir/ssl.conf
|
|
|
|
do_rsync $httpdconfdir/ssl.conf
|
|
|
|
do_rsync /usr/local/nagios
|
|
|
|
do_rsync /usr/local/nagios
|
|
|
|
do_rsync /usr/local/nagiosmobile
|
|
|
|
do_rsync /usr/local/nagiosmobile
|
|
|
|
do_rsync /usr/local/nagiosxi
|
|
|
|
do_rsync /usr/local/nagiosxi custom-includes/css/
|
|
|
|
do_rsync /usr/local/nagvis
|
|
|
|
do_rsync /usr/local/nagvis
|
|
|
|
do_rsync /usr/local/nrdp
|
|
|
|
do_rsync /usr/local/nrdp
|
|
|
|
do_rsync /usr/share/snmp
|
|
|
|
do_rsync /usr/share/snmp
|
|
|
|
@ -163,7 +160,6 @@ do_rsync /var/lib/mrtg
|
|
|
|
do_rsync /var/spool/cron/apache
|
|
|
|
do_rsync /var/spool/cron/apache
|
|
|
|
do_rsync /var/spool/cron/crontabs/$apacheuser
|
|
|
|
do_rsync /var/spool/cron/crontabs/$apacheuser
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} # End of do_backup_files
|
|
|
|
} # End of do_backup_files
|
|
|
|
|
|
|
|
|
|
|
|
do_backup_sql() {
|
|
|
|
do_backup_sql() {
|
|
|
|
@ -283,8 +279,6 @@ test_mysql_connection() {
|
|
|
|
|
|
|
|
|
|
|
|
rootdir=/store/backups/nagiosxi
|
|
|
|
rootdir=/store/backups/nagiosxi
|
|
|
|
backupfile=$1
|
|
|
|
backupfile=$1
|
|
|
|
# This is a poor way to write this, but it's the easiest. Skip doing all the restore operations if there's no file to restore from.
|
|
|
|
|
|
|
|
if [ ! $noFile ]; then
|
|
|
|
|
|
|
|
if [ ! -f $backupfile ]; then
|
|
|
|
if [ ! -f $backupfile ]; then
|
|
|
|
error "Unable to find backup file $backupfile!"
|
|
|
|
error "Unable to find backup file $backupfile!"
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
@ -483,7 +477,7 @@ else
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi # This is from the "noFile" check previously
|
|
|
|
|
|
|
|
##############################
|
|
|
|
##############################
|
|
|
|
# RESTART SERVICES
|
|
|
|
# RESTART SERVICES
|
|
|
|
##############################
|
|
|
|
##############################
|
|
|
|
@ -504,9 +498,12 @@ echo "==============="
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
do_secondary() {
|
|
|
|
do_secondary() {
|
|
|
|
[ ! $noFile -a ! -r "$syncfile" ] && error "No sync file ($syncfile) found." && exit 2
|
|
|
|
[ ! -r "$syncfile" ] && error "No sync file ($syncfile) found." && exit 2
|
|
|
|
restore_secondary "$syncfile"
|
|
|
|
restore_secondary "$syncfile"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
|
|
|
|
if [ -r "/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.secondary" -a -w "/usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css" ]; then
|
|
|
|
|
|
|
|
cp /usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css.secondary /usr/local/nagiosxi/html/includes/components/custom-includes/css/header-gradient.css
|
|
|
|
|
|
|
|
fi
|
|
|
|
rm -f ${syncfile}
|
|
|
|
rm -f ${syncfile}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
} # End of do_secondary
|
|
|
|
} # End of do_secondary
|
|
|
|
|