You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-homelab/playbooks/backup-docker-volumes.yml

39 lines
1.1 KiB
YAML

---
- hosts: qnap
become: true
vars:
# corrsponds to which category of backups will be used.
# determined based on the docker labels.
schedule: nightly
pre_tasks:
- name: Include vault variables.
include_vars: '../{{vault_file}}'
tags: [always]
tasks:
- name: Find Containers With Backup Label
register: docker_info
docker_host_info:
containers: true
containers_filters:
label:
- "ie.cianhatton.backup.enabled=true"
- "ie.cianhatton.backup.schedule={{ schedule }}"
register: filter_output
- debug: msg="{{filter_output}}"
- name: Get Container Names
set_fact: container_names="{{ filter_output.containers | map(attribute="Names") | flatten }}"
- debug: msg="{{container_names}}"
- name: Backup Containers with backup label
include_role:
name: chatton.docker_backup.docker_s3_backup
vars:
container_backup: "{{ container_item | regex_replace('^\\/', '') }}"
with_items: "{{ container_names }}"
loop_control:
loop_var: container_item