|
|
|
@ -14,6 +14,7 @@ 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
|
|
|
|
@ -38,6 +39,7 @@ 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 ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -61,6 +63,9 @@ 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
|
|
|
|
@ -278,6 +283,8 @@ 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
|
|
|
|
@ -476,7 +483,7 @@ else
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi # This is from the "noFile" check previously
|
|
|
|
##############################
|
|
|
|
##############################
|
|
|
|
# RESTART SERVICES
|
|
|
|
# RESTART SERVICES
|
|
|
|
##############################
|
|
|
|
##############################
|
|
|
|
@ -497,7 +504,7 @@ echo "==============="
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
do_secondary() {
|
|
|
|
do_secondary() {
|
|
|
|
[ ! -r "$syncfile" ] && error "No sync file ($syncfile) found." && exit 2
|
|
|
|
[ ! $noFile -a ! -r "$syncfile" ] && error "No sync file ($syncfile) found." && exit 2
|
|
|
|
restore_secondary "$syncfile"
|
|
|
|
restore_secondary "$syncfile"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
rm -f ${syncfile}
|
|
|
|
rm -f ${syncfile}
|
|
|
|
|