ansible-role-gitea/handlers/backup.yaml

31 lines
816 B
YAML
Raw Normal View History

- name: Get stats of docker-compose.yaml
ansible.builtin.stat:
path: /opt/gitea/docker-compose.yaml
register: docker_compose_stat
listen:
- Backup Gitea
2023-05-01 22:38:08 +02:00
- name: Stop Gitea for backup
2024-04-10 19:57:47 +02:00
community.docker.docker_compose_v2:
2023-05-01 01:48:07 +02:00
project_src: /opt/gitea
state: present
stopped: true
register: docker_compose
2023-05-01 01:48:07 +02:00
listen:
- Backup Gitea
notify:
- Ensure Gitea is running
when: docker_compose_stat.stat.exists is defined and docker_compose_stat.stat.exists
2023-05-01 01:48:07 +02:00
2023-05-01 22:38:08 +02:00
- name: Backup Gitea directory
2023-05-01 18:07:56 +02:00
community.general.archive:
path: /opt/gitea/
2024-04-10 19:41:22 +02:00
dest: "/var/backups/gitea-{{ gitea.hostname }}.{{ gitea.domain }}@{{ lookup('pipe', 'date -u +%Y-%m-%dT%H:%M:%SZ') }}.tar.gz"
2023-05-01 18:07:56 +02:00
force_archive: true
format: gz
owner: root
mode: "400"
2023-05-01 01:48:07 +02:00
listen:
- Backup Gitea
register: backup