library/roles/mysql: Some fixes to the mysql backup scripts.

This commit is contained in:
Andrea Dell'Amico 2016-01-11 11:00:55 +01:00
parent 40cd9400e3
commit a4025969f8
4 changed files with 14 additions and 5 deletions

View File

@ -44,6 +44,4 @@ mysql_backup_logfile: '{{ mysql_backup_logdir }}/my_backup.log'
mysql_backup_retain_copies: 15
mysql_backup_destdir: /var/lib/mysql-backup
mysql_backup_exclude_list: "performance_schema"
mysql_backup_crontab_minute: 0
mysql_backup_crontab_hour: 2

View File

@ -64,6 +64,7 @@ if [ ! -f $LOCKFILE ] ; then
echo "$TIMESTAMP" > $TIMESTAMP_LOG
rm -f $LOCKFILE
else
echo "Old backup still running" > /var/log/mysql-backup.log
RETVAL=2
if [ "${MY_BACKUP_USE_NAGIOS}" == "True" ] ; then
echo "old backup still running:WARNING" >> $NAGIOS_LOG

View File

@ -1,6 +1,6 @@
---
- name: Install a script that performs mysql dumps
copy: src=mysql-backup.sh dest=/usr/local/bin/mysql-backup owner=root group=root mode=0750
copy: src=mysql-backup.sh dest=/usr/local/sbin/mysql-backup owner=root group=root mode=0750
tags: [ 'mysql', 'mysql_backup' ]
- name: Install the mysql backup defaults
@ -8,5 +8,5 @@
tags: [ 'mysql', 'mysql_backup' ]
- name: Cron job that executes mysql nightly backups
copy: src=mysql-backup.cron dest=/etc/cron.d/mysql-backup owner=root group=root mode=0644
copy: src=mysql-backup.cron dest=/etc/cron.daily/mysql-backup owner=root group=root mode=0755
tags: [ 'mysql', 'mysql_backup' ]

View File

@ -1 +1,11 @@
{{ mysql_backup_crontab_minute }} {{ mysql_backup_crontab_hour }} * * * root /usr/local/bin/mysql-backup > /var/log/mysql-backup.log 2>&1
#!/bin/bash
LOG_FILE=/var/log/mysql-backup.log
if [ -x /etc/cron.daily/duplicity_backup ] ; then
echo "duplicity backups active. Exiting" > $LOG_FILE
exit 0
fi
/usr/local/sbin/mysql-backup > $LOG_FILE 2>&1
exit 0