1

Topic: mysql backup script

==== Required information ====
- iRedMail version: 0.9.1
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): Apache
- Linux/BSD distribution name and version: Debian 8
- Related log if you're reporting an issue:
====

Last day I replaced the backup script from 0.9.1 with the one from the 0.8.x series and have run into a minor problem. The backup of the chosen databases is performed as expected and backup files are found where they should be found the problem is that the log file is empty and the mail sent to postmaster only contains the following:

==> Backup completed successfully.
==> Detailed log (/var/vmail/backup/mysql/2015/05/29/2015-05-29-03:30:01.log): 
=========================

From the iredmail server:
root@iredmail:/var/vmail/backup/mysql/2015/05/29# ll
total 528
-rw-r--r-- 1 root root      0 May 29 03:30 2015-05-29-03:30:01.log
-rw-r--r-- 1 root root 251180 May 29 03:30 amavisd-2015-05-29-03:30:01.sql.bz2
-rw-r--r-- 1 root root  78742 May 29 03:30 cluebringer-2015-05-29-03:30:01.sql.bz2
-rw-r--r-- 1 root root  10096 May 29 03:30 iredadmin-2015-05-29-03:30:01.sql.bz2
-rw-r--r-- 1 root root 104758 May 29 03:30 mysql-2015-05-29-03:30:01.sql.bz2
-rw-r--r-- 1 root root  84987 May 29 03:30 roundcubemail-2015-05-29-03:30:01.sql.bz2

Any idea what have gone wrong and where to look for the bug?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2 (edited by GMF 2015-05-29 17:42:01)

Re: mysql backup script

Hi

-rw-r--r-- 1 root root      0 May 29 03:30 2015-05-29-03:30:01.log

here is your problem.

The backup script you are using is not appending logs to the "2015-05-29-03:30:01.log" file placed in the same dir of your backups.
If you look closer you will see that file "2015-05-29-03:30:01.log" is empty.

Logwatch (the tool used to send you the daily mail with the logs) include that file in the section of the email, so thats why you are getting it empty.

Check out the .log file in the previous days backup directories, generated by the backup script shipped with iredmail 0.9.1 and you will see what you are missing.
I suppose you could add the logging function to the backup script you chose to use.

3 (edited by mir 2015-05-29 23:13:07)

Re: mysql backup script

But the old backup script did create log files with content so this is a regression in the backup script in 0.9.1.

root@iredmail:/var/vmail/backup/mysql/2015/05/28# cat 2015-05-28-03:30:01.log
* Starting backup: 2015-05-28-03:30:01.
* Backup directory: /var/vmail/backup/mysql/2015/05/28.
* Backing up databases ...
* File size:
----
268K    /var/vmail/backup/mysql/2015/05/28/amavisd-2015-05-28-03:30:01.sql.bz2
80K    /var/vmail/backup/mysql/2015/05/28/cluebringer-2015-05-28-03:30:01.sql.bz2
12K    /var/vmail/backup/mysql/2015/05/28/iredadmin-2015-05-28-03:30:01.sql.bz2
104K    /var/vmail/backup/mysql/2015/05/28/mysql-2015-05-28-03:30:01.sql.bz2
84K    /var/vmail/backup/mysql/2015/05/28/roundcubemail-2015-05-28-03:30:01.sql.bz2
----
* Backup completed (Success? YES).

4

Re: mysql backup script

Could you please use the one in development version? It was fixed:
Https://bitbucket.org/zhb/iredmail/src

5

Re: mysql backup script

ZhangHuangbin wrote:

Could you please use the one in development version? It was fixed:
Https://bitbucket.org/zhb/iredmail/src

I only have problems with backup_mysql.sh and the version on bitbucket is identical to the one in current release. It can also be noted that running the script from the command line results in expected behavior. It seems the problem occurs when the script is run by cron.

6 (edited by mir 2015-05-30 17:11:19)

Re: mysql backup script

I think I have found the error

if [ X"${REMOVE_OLD_BACKUP}" == X'YES' -a -d ${REMOVED_BACKUP_DIR} ]; then
    echo -e "* Delete old backup: ${REMOVED_BACKUP_DIR}." >> ${LOGFILE}
    rm -rf ${REMOVED_BACKUP_DIR} >/dev/null 2>${LOGFILE}

    sql_log_msg="INSERT INTO log (event, loglevel, msg, admin, ip, timestamp) VALUES ('backup', 'info', 'Remove old backup: ${REMOVED_BACKUP_DIR}.', 'cron_backup_sql', '127.0.0.1', NOW());"
    ${CMD_MYSQL} -u"${MYSQL_USER}" -p"${MYSQL_PASSWD}" iredadmin -e "${sql_log_msg}"
fi

Above line:
rm -rf ${REMOVED_BACKUP_DIR} >/dev/null 2>${LOGFILE}
Should be changed to:
rm -rf ${REMOVED_BACKUP_DIR} >/dev/null 2>>${LOGFILE}

See attached patch file.

Post's attachments

fix_broking_logging.patch 689 b, 2 downloads since 2015-05-30 

You don't have the permssions to download the attachments of this post.

7

Re: mysql backup script

Fixed. Thanks for the feedback.