From a6232e8d4a4a04ae565fe40a13f37791b2b9d33f Mon Sep 17 00:00:00 2001 From: Christian Steinle Date: Thu, 24 Apr 2025 10:05:40 +0200 Subject: [PATCH] First test for backup minisforum. --- minisforum.yaml | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 minisforum.yaml diff --git a/minisforum.yaml b/minisforum.yaml new file mode 100644 index 0000000..2933716 --- /dev/null +++ b/minisforum.yaml @@ -0,0 +1,62 @@ +--- + +# Version 1.1.0 +# Encrypt passwords with: "ansible-vault encrypt_string" +# Start playbook with: "ansible-playbook -i localhost, -u chsteinle -k playbook-yaml.yml --ask-vault-pass" + +- name: Docker backup + hosts: all + gather_facts: false + vars: + backup_location: "/docker/backup/" + + tasks: + - name: Include container variables + include_vars: containers.yml + + # - name: Display container variables + # ansible.builtin.debug: + # msg: '{{ containers }}' + + - name: Check if directory for container backup exists + ansible.builtin.debug: + msg: "{{ item.name }}" + loop: "{{ containers }}" + loop_control: + label: "{{ item.name }}" + + - name: Create backup of mysql database and store to backup directory + ansible.builtin.debug: + msg: + - '{{ item[1] }}' # Database configuration @see: when + - '{{ item[0].name }}' # Container name + when: item[1].type == "mysql" + loop: "{{ containers | subelements('database', skip_missing=True) }}" + loop_control: + label: "{{ item[1].name }}" + + - name: Create backup of postgres database and store to backup directory + ansible.builtin.debug: + msg: + - '{{ item[1] }}' # Database configuration @see: when + - '{{ item[0].name }}' # Container name + when: item[1].type == "psql" + loop: "{{ containers | subelements('database', skip_missing=True) }}" + loop_control: + label: "{{ item[1].name }}" + + - name: Gzip all database backup files + ansible.builtin.debug: + msg: '{{ item[0].name }}' # Container name + loop: "{{ containers | subelements('database', skip_missing=True) }}" + loop_control: + label: "{{ item[1].name }}" + + - name: Create backup of volume and store to backup directory + ansible.builtin.debug: + msg: + - '{{ item[1] }}' # Volume name + - '{{ item[0].name }}' # Container name + loop: "{{ containers | subelements('volumes', skip_missing=True) }}" + loop_control: + label: "{{ item[1] }}"