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.
 
 
 
 
 
 

39 lines
1.9 KiB

#!/bin/bash -e
mkdir -p /home/lbkp/zabbix
# First, backup the schema
/usr/bin/mysqldump --user={{ zabbix_server_db_user | quote }} \
--password={{ zabbix_server_db_pass | quote }} \
--host={{ zabbix_server_db_server | quote }} \
--port={{ zabbix_server_db_port }} \
--no-data \
--quick --single-transaction \
--add-drop-table {{ zabbix_server_db_name | quote }} | zstd -T0 -c > /home/lbkp/zabbix/{{ zabbix_server_db_name }}_schema.sql.zstd
# Then, backup data
{% if zabbix_server_backup_on_full_only %}
if [[ "$1" == "full" ]]; then
/usr/bin/mysqldump --user={{ zabbix_server_db_user | quote }} \
--password={{ zabbix_server_db_pass | quote }} \
--host={{ zabbix_server_db_server | quote }} \
--port={{ zabbix_server_db_port }} \
--no-create-info \
--quick --single-transaction \
--add-locks \
{{ zabbix_server_db_name | quote }} | zstd -T0 -c > /home/lbkp/zabbix/{{ zabbix_server_db_name }}_data.sql.zstd
else
{% endif %}
/usr/bin/mysqldump --user={{ zabbix_server_db_user | quote }} \
--password={{ zabbix_server_db_pass | quote }} \
--host={{ zabbix_server_db_server | quote }} \
--port={{ zabbix_server_db_port }} \
--no-create-info \
{% for table in ['events', 'history', 'history_uint', 'history_str', 'history_text', 'trends', 'trends_uint'] %}
--ignore-table={{ zabbix_server_db_name }}.{{ table }} \
{% endfor %}
--quick --single-transaction \
--add-locks \
{{ zabbix_server_db_name | quote }} | zstd -T0 -c > /home/lbkp/zabbix/{{ zabbix_server_db_name }}_data.sql.zstd
{% if zabbix_server_backup_on_full_only %}
fi
{% endif %}