{% from 'lib.sls' import container_deploy with context %}
{% set user = salt['pillar.get']('podman:user', 'root') %}
{% set home = salt['user.info'](user).home %}
Create backup destination for mariadb backups:
file.directory:
- name: {{ pillar.containers.mariadb.backup_dir }}
- user: {{ user }}
- group: root
- mode: "0750"
Create backup script:
file.managed:
- name: {{ home }}/bin/mysql-dump.sh
- source: salt://podman/files/mysql-dump.sh.jinja
- template: jinja
- mode: "0700"
Create mariadb dump service:
- name: /etc/systemd/system/mysql-dump.service
- source: salt://podman/files/mysql-dump.service.jinja
- user: root
- mode: "0644"
Create mariadb dump timer:
- name: /etc/systemd/system/mysql-dump.timer
- source: salt://podman/files/mysql-dump.timer.jinja
Reload systemd daemon for mariadb dump:
cmd.run:
- name: systemctl daemon-reload
- onchanges:
- file: Create mariadb dump service
- file: Create mariadb dump timer
Start mariadb dump timer:
service.running:
- name: mysql-dump.timer
- enable: True
{{ container_deploy('mariadb') }}