Commit ec6e099e authored by bgm's avatar bgm Committed by bgm
Browse files

ansible: Update the mysqlbackup role (upstream)

parent bbd49e90
...@@ -5,6 +5,7 @@ Includes: ...@@ -5,6 +5,7 @@ Includes:
* Installation of https://cytopia.github.io/mysqldump-secure/ * Installation of https://cytopia.github.io/mysqldump-secure/
* Included/patched in this repo, because by default it makes it hard to use /etc/mysql/debian.cnf * Included/patched in this repo, because by default it makes it hard to use /etc/mysql/debian.cnf
* Also patched to allow overwriting existing files, to avoid rdiff backup growth, and avoid need for tmpreaper.
* Configuration inspired from https://github.com/infOpen/ansible-role-mysql-backup/ * Configuration inspired from https://github.com/infOpen/ansible-role-mysql-backup/
Overview (assuming defaults): Overview (assuming defaults):
...@@ -12,6 +13,4 @@ Overview (assuming defaults): ...@@ -12,6 +13,4 @@ Overview (assuming defaults):
* MySQL dumps are stored in: /var/backups/mysql/ * MySQL dumps are stored in: /var/backups/mysql/
* The cron runs daily, around 20:30 because rdiff-backup runs at 21:00 (UTC) * The cron runs daily, around 20:30 because rdiff-backup runs at 21:00 (UTC)
* Runs using the Debian sys-maint (/etc/mysql/debian.cnf) * Runs using the Debian sys-maint (/etc/mysql/debian.cnf)
* Logs in: /var/log/mysql/mysqldump-secure.log * Logs in: /var/backups/mysqldump-secure.monitoring.log (monitored by Icinga)
* TODO: log rotation?
* TODO: /var/log/mysql/mysqldump-secure.monitoring.log can be monitored by check_mysqldump-secure
...@@ -4661,20 +4661,21 @@ for db in ${DB_LIST_ALL}; do ...@@ -4661,20 +4661,21 @@ for db in ${DB_LIST_ALL}; do
DB_CNT_IGNORED=$((DB_CNT_IGNORED + 1)) DB_CNT_IGNORED=$((DB_CNT_IGNORED + 1))
DB_LIST_IGNORED="$( str_join "${DB_LIST_IGNORED}" "," "${db}" )" DB_LIST_IGNORED="$( str_join "${DB_LIST_IGNORED}" "," "${db}" )"
# # [ML] SYMBIOTIC We keep the same file name to limit rdiff backup growth
# Main case 2 (file exists on disk) # #
# # # Main case 2 (file exists on disk)
elif [ -f "${DUMP_DIR}/${DUMP_FILE_PRE}${db}${ext}" ]; then # #
# elif [ -f "${DUMP_DIR}/${DUMP_FILE_PRE}${db}${ext}" ]; then
# Increment counters #
DB_CNT_FAILED=$((DB_CNT_FAILED + 1)) # # Increment counters
MDS_FAIL_COUNT=$((MDS_FAIL_COUNT + 1)) # DB_CNT_FAILED=$((DB_CNT_FAILED + 1))
# MDS_FAIL_COUNT=$((MDS_FAIL_COUNT + 1))
# Add failed db to nagios log #
DB_LIST_FAILED="$( str_join "${DB_LIST_FAILED}" "," "${db}" )" # # Add failed db to nagios log
# DB_LIST_FAILED="$( str_join "${DB_LIST_FAILED}" "," "${db}" )"
debug "fatal" "(RUN): ${_cnt} Failed: ${db} cannot be written to disk (file exists: ${DUMP_DIR}/${DUMP_FILE_PRE}${db}${ext})" "${OUT_VERBOSITY}" "${LOG_VERBOSITY}" "${LOG_FILE}" #
NAGIOS_EXIT_CODE="$(merge_exit_codes "${NAGIOS_EXIT_CODE}" 2)" # debug "fatal" "(RUN): ${_cnt} Failed: ${db} cannot be written to disk (file exists: ${DUMP_DIR}/${DUMP_FILE_PRE}${db}${ext})" "${OUT_VERBOSITY}" "${LOG_VERBOSITY}" "${LOG_FILE}"
# NAGIOS_EXIT_CODE="$(merge_exit_codes "${NAGIOS_EXIT_CODE}" 2)"
# #
# Main case 3 (dumping) # Main case 3 (dumping)
......
...@@ -3,16 +3,25 @@ ...@@ -3,16 +3,25 @@
# Based on: # Based on:
# https://github.com/openmicroscopy/ansible-role-mysql-backup/ # https://github.com/openmicroscopy/ansible-role-mysql-backup/
# Required to cleanup backups after 24h # Not used now that we overwrite the previous backup with the same name.
- apt: name={{ item }} state=present install_recommends=no # # Required to cleanup backups after 24h
with_items: # - apt: name={{ item }} state=present install_recommends=no
- tmpreaper # with_items:
tags: # - tmpreaper
- mysqlbackup # when: ansible_distribution == "Debian"
- packages # tags:
# - mysqlbackup
# - packages
#
# - yum: name={{ item }} state=present
# with_items:
# - tmpwatch
# when: ansible_distribution == "CentOS"
# tags:
# - mysqlbackup
# - packages
- name: mysqlbackup | create backup directory - name: mysqlbackup | create backup directory
become: yes
file: file:
path: "{{ mysqlbackup_backupdir }}" path: "{{ mysqlbackup_backupdir }}"
recurse: yes recurse: yes
...@@ -20,8 +29,16 @@ ...@@ -20,8 +29,16 @@
tags: tags:
- mysqlbackup - mysqlbackup
- name: mysqlbackup | chgrp aegir if Aegir server
file:
path: "{{ mysqlbackup_backupdir }}"
owner: root
group: aegir
when: "'symbiotic-aegir-vm' in group_names"
tags:
- mysqlbackup
- name: mysqlbackup | create backup tmp directory - name: mysqlbackup | create backup tmp directory
become: yes
file: file:
path: "{{ mysqlbackup_backupdir }}/tmp" path: "{{ mysqlbackup_backupdir }}/tmp"
recurse: yes recurse: yes
......
...@@ -14,12 +14,17 @@ TMP_DIR="{{ mysqlbackup_backupdir }}/tmp" ...@@ -14,12 +14,17 @@ TMP_DIR="{{ mysqlbackup_backupdir }}/tmp"
# NOTE: Must be chmod 0400 # NOTE: Must be chmod 0400
MYSQL_CNF_FILE="{{ mysqlbackup_cnf_file }}" MYSQL_CNF_FILE="{{ mysqlbackup_cnf_file }}"
# For Zimbra servers
if [ -d "/opt/zimbra/common/bin/" ]; then
PATH="$PATH:/opt/zimbra/common/bin/"
fi
# File/Folder permission of Target directory ($TARGET) # File/Folder permission of Target directory ($TARGET)
# and the actual dumped databases. # and the actual dumped databases.
# If not otherwise needed, leave the # If not otherwise needed, leave the
# protective secure default values # protective secure default values
DUMP_DIR_CHMOD="700" DUMP_DIR_CHMOD="750"
DUMP_FILE_CHMOD="400" DUMP_FILE_CHMOD="440"
# mysqldump options # mysqldump options
# --routines (Off by default) # --routines (Off by default)
...@@ -51,10 +56,10 @@ COMPRESS={{ mysqlbackup_mysqldump_compress_active }} ...@@ -51,10 +56,10 @@ COMPRESS={{ mysqlbackup_mysqldump_compress_active }}
COMPRESS_BIN="gzip" COMPRESS_BIN="gzip"
COMPRESS_EXT="gz" COMPRESS_EXT="gz"
COMPRESS_ARG="-6" COMPRESS_ARG="-6 --rsyncable"
# The script is whiny if these defaults aren't set. # The script is whiny if these defaults aren't set.
DUMP_FILE_PRE="$(date '+%Y-%m-%d')_" DUMP_FILE_PRE="db_"
MYSQL_OPTS_QUICK_MIN_SIZE=200 MYSQL_OPTS_QUICK_MIN_SIZE=200
CONSISTENT_DUMP_ONLY_INNODB=1 CONSISTENT_DUMP_ONLY_INNODB=1
CONSISTENT_DUMP_NO_INNODB=1 CONSISTENT_DUMP_NO_INNODB=1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment