Ansible roles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.2 KiB

#!/bin/sh
set -e
# Get the .my.cnf from root
HOME=/root
PATH=/usr/bin:$PATH
DEST=/home/lbkp/mysql
[ -d $DEST ] || mkdir -p $DEST
for DB in $(/usr/bin/mysqlshow | /bin/awk '{print $2}' | /bin/grep -v Databases)
do
{% for db in mysql_skip_backup %}
# {{ db }} is configured not to be backed up
if [[ "$DB" == "{{ db }}" ]]; then
continue
fi
{% endfor %}
{% if mysql_compress_cmd %}
{% if mysql_compress_cmd is search('p?xz') %}
{% set compext = 'xz' %}
{% elif mysql_compress_cmd is search('p?bzip2') %}
{% set compext = 'bz2' %}
{% elif mysql_compress_cmd is search('(pi)?gz') %}
{% set compext = 'gz' %}
{% elif mysql_compress_cmd is search('lzop') %}
{% set compext = 'lzo' %}
{% elif mysql_compress_cmd is search('lz4') %}
{% set compext = 'lz4' %}
{% elif mysql_compress_cmd is search('zstd') %}
{% set compext = 'zstd' %}
{% else %}
{% set compext = 'z' %}
{% endif %}
/usr/bin/mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table $DB | /bin/nice -n 10 {{ mysql_compress_cmd }} > $DEST/$DB.sql.{{ compext }}
{% else %}
/usr/bin/mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table $DB -r $DEST/$DB.sql
{% endif %}
done