ansible-role-gitea/handlers/backup.yaml
Marius Meyer 14da8cd5a1
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 36s
gitea data/config base_path var
2024-06-03 14:29:14 +02:00

30 lines
816 B
YAML

- name: Get stats of docker-compose.yaml
ansible.builtin.stat:
path: /opt/gitea/docker-compose.yaml
register: docker_compose_stat
listen:
- Backup Gitea
- name: Stop Gitea for backup
community.docker.docker_compose_v2:
project_src: /opt/gitea
state: stopped
register: docker_compose
listen:
- Backup Gitea
notify:
- Ensure Gitea is running
when: docker_compose_stat.stat.exists is defined and docker_compose_stat.stat.exists
- name: Backup Gitea directory
community.general.archive:
path: "{{ gitea_vars.base_path }}/"
dest: "/var/backups/gitea-{{ gitea.hostname }}.{{ gitea.domain }}@{{ lookup('pipe', 'date -u +%Y-%m-%dT%H:%M:%SZ') }}.tar.gz"
force_archive: true
format: gz
owner: root
mode: "400"
listen:
- Backup Gitea
register: backup