This commit is contained in:
olli 2024-08-04 22:40:10 +02:00
parent a6b821534c
commit d07f953730

View File

@ -193,6 +193,29 @@
chdir: /home/docker/mariadb.{{inventory_hostname}} chdir: /home/docker/mariadb.{{inventory_hostname}}
creates: /home/docker/mariadb.{{inventory_hostname}}/ssl/certificate.pem creates: /home/docker/mariadb.{{inventory_hostname}}/ssl/certificate.pem
- name: /usr/local/sbin/autoupdate.d/mariadb-ssl.update
blockinfile:
path: /usr/local/sbin/autoupdate.d/mariadb-ssl.update
create: yes
mode: 0550
owner: root
group: root
marker: "# {mark} ANSIBLE MANAGED BLOCK"
block: |
. /home/docker/_defaults/mariadb/envroot.db
DAYS=7
TIMESTAMP=$(date +"%Y%m%d%H%M")
mariadb-dump -u root -h mariadb.{{inventory_hostname}} --ssl --ssl-verify-server-cert -P 33306 -p${MARIADB_ROOT_PASSWORD} --all-databases >${g_tmp}/dberr | gzip > $BACKUPDIR/MARIADB-$TIMESTAMP.sql.gz || g_echo_error "MariaDB Backup failed $(cat ${g_tmp}/dberr)"
unset MARIADB_ROOT_PASSWORD
# dont delete last old backups!
OLD_BACKUPS=$(ls -1 $BACKUPDIR/$i*.gz | wc -l)
if [ $OLD_BACKUPS -gt $DAYS ]; then
find $BACKUPDIR -name "$i*.gz" -daystart -mtime +$DAYS -delete
fi
backup: yes
validate: /bin/bash -n %s
handlers: handlers:
- name: Restart mariadb - name: Restart mariadb