Nagios Fusion 4.0.0
full=4.0.0
major=4
minor=0.0
releasedate=2017-07-17
release=4000
[root@nagios-fusion scripts]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
37G 24G 12G 66% /
tmpfs 931M 0 931M 0% /dev/shm
/dev/sda1 477M 95M 357M 22% /boot
I was able to take a backup a few months ago. ls -la 1502307633.tar.gz
7804057 Aug 9 15:41 1502307633.tar.gz
Have I changed any passwords?
nope, never touched mysql
RE: mysql -u root -pfusion
Yes, I could get in that way, I connected in fine.
So, the test shows the password has not changed, yet I get this. Same result if its prefixed with 'sudo'
[root@nagios-fusion ~]# /usr/local/nagiosfusion/scripts/backup_fusion.sh
Backing up Nagios Fusion directory...
tar: Removing leading `/' from member names
Backing up MySQL databases...
mysqldump: Got errno 28 on write
Error backing up MySQL database 'fusion' - check the password in this script!
Code: Select all
[root@nagios-fusion scripts]# cat backup_fusion.sh
#!/bin/bash
BASEDIR=$(dirname $(readlink -f $0))
# Import all CFG variables
. $BASEDIR/../var/fusion-sys.cfg
php $BASEDIR/import_fusionconfig.php > $BASEDIR/config.dat
. $BASEDIR/config.dat
rm $BASEDIR/config.dat
BACKUPLOG="$proddir/var/log/backup.log"
ts=`date +%s`
###############################
# USAGE / HELP
###############################
usage () {
echo ""
echo "Use this script to backup Nagios Fusion."
echo ""
echo " -n | --name Set the full name of the backup minus the .tar.gz"
echo " -p | --prepend Prepend a string to the .tar.gz name (ignored when using -n)"
echo " -a | --append Append a string to the .tar.gz name (ignored when using -n)"
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 | --prepen)dm
prepend=$2"."
;;
-a | --append)
append="."$2
;;
-d | --directory)
rootdir=$2
;;
esac
shift
done
if [ -z $rootdir ]; then
rootdir="/store/backups/nagiosfusion"
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
##############################
echo "Backing up Nagios Fusion directory..."
tar czfp $mydir/nagiosfusion.tar.gz /usr/local/nagiosfusion
##############################
# BACKUP DATABASES
##############################
mkdir -p $mydir/mysql
echo "Backing up MySQL databases..."
mysqldump -h $cfg__database__fusion__host -u $cfg__database__fusion__user --password="$cfg__database__fusion__pass" --add-drop-database -B $cfg__database__fusion__dbname > $mydir/mysql/fusion.sql
res=$?
if [ $res != 0 ]; then
echo "Error backing up MySQL database 'fusion' - check the password in this script!" | tee -a $BACKUPLOG
rm -r $mydir
exit $res;
fi
##############################
# BACKUP CRONJOB ENTRIES
##############################
mkdir -p $mydir/cron
echo "Backing up nagiosfusion cronjob..."
cp /etc/cron.d/nagiosfusion $mydir/cron/nagiosfusion
echo "Backing up cronjobs for Apache..."
cp /var/spool/cron/apache $mydir/cron/apache
##############################
# BACKUP SUDOERS
##############################
sudoers=/etc/sudoers.d/nagiosfusion
if [ -f "$sudoers" ]; then
mkdir -p $mydir/sudoers
echo "Backing up nagiosfusion sudoers.d file..."
cp $sudoers $mydir/sudoers
fi
##############################
# BACKUP LOGROTATE
##############################
echo "Backing up logrotate config files..."
mkdir -p $mydir/logrotate
cp -rp /etc/logrotate.d/nagiosfusion $mydir/logrotate
##############################
# BACKUP APACHE CONFIG FILES
##############################
echo "Backing up Apache config files..."
mkdir -p $mydir/httpd
cp -rp $httpdconfdir/nagiosfusion.conf $mydir/httpd
##############################
# 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
One strange thing is that fusion-sys.cfg does show the correct password for the db, however when you run it by hand you have no space between the -p and password and it works. If you add the space manually, it does not work.
Another thing I noticed is that cfg_database_fusion_user is fusion not root. Manually (just running the mysql command I can connect with both root and the fusion user, using the default password.
Code: Select all
[root@nagios-fusion scripts]# ./import_fusionconfig.php --help
cfg__root_dir='/usr/local/nagiosfusion'
cfg__base_url='/nagiosfusion'
cfg__database__connection_timeout=10
cfg__database__fusion__type='mysql'
cfg__database__fusion__user='fusion'
cfg__database__fusion__pass='fusion'
cfg__database__fusion__host='localhost'
cfg__database__fusion__port=''
cfg__database__fusion__dbname='fusion'
cfg__database__fusion__persist=1
Why is there an import script, but no output script?
Breaking down the above backup script manually and running each piece works. For example I just ran the mysqldump command to /store/backups/fusion_dump.sql and it seems to be running fine. Actually, I had to kill it. It was 99% full disk space up to 17 GB on the dump. So, I need to figure out how the db got this big and how to get rid or archive some .