- name: Backup MySQL database community.docker.docker_container_exec: container: hedgedoc-mysql docker_host: "unix:///run/user/{{ host_uid }}/docker.sock" argv: - /bin/bash - "-c" - "mysqldump hedgedoc > /var/lib/mysql/hedgedoc-dump.sql" env: MYSQL_PWD: "{{ hedgedoc_secrets['mysql_root_password'] if hedgedoc_secrets['mysql_root_password'] is defined else lookup('ansible.builtin.file', hedgedoc_mysql_root_password_file) }}" - name: Create borg backup command: cmd: | borg create --compression=lzma "{{ borg_repodir }}::{{ role_name }}-{now:%Y-%m-%d_%H-%M-%S}" {{ volumes['hedgedoc_mysql_datadir'] }}/hedgedoc-dump.sql environment: BORG_PASSCOMMAND: "cat {{ borg_passphrase_file }}" become: true - name: Prune borg repository command: cmd: | borg prune --glob-archives='{{ role_name }}-*' {{ borg_prune_options }} {{ borg_repodir }} environment: BORG_PASSCOMMAND: "cat {{ borg_passphrase_file }}" become: true