Ansible/gitlab/tasks/backup.yml

30 lines
810 B
YAML
Raw Normal View History

2022-02-11 16:49:06 +00:00
---
# tasks file for gitlab
- name: Ensure a gitlab container is running.
docker_container:
name: "{{ gitlab_container_name }}"
state: present
2022-02-14 00:02:14 +00:00
image: gitlab/gitlab-ce
2022-02-11 16:49:06 +00:00
comparisons:
'*': ignore
- name: Start gitlab backup
community.docker.docker_container_exec:
container: "{{ gitlab_container_name }}"
command: gitlab-backup create GZIP_RSYNCABLE=yes SKIP=registry
- name: Get list of backups
find:
paths: "{{ gitlab_backup_directory }}"
register: found_files
- name: Get latest backup
set_fact:
latest_file: "{{ found_files.files | sort(attribute='mtime',reverse=true) | first }}"
- name: Download latest backup from remote
ansible.posix.synchronize:
src: "{{ latest_file.path }}"
2022-02-14 00:02:14 +00:00
dest: "{{ gitlab_local_backup_directory }}"/backups
2022-02-11 16:49:06 +00:00
mode: pull