First test for backup minisforum.
This commit is contained in:
62
minisforum.yaml
Normal file
62
minisforum.yaml
Normal file
@@ -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] }}"
|
||||||
Reference in New Issue
Block a user