1
1
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_gitea.git synced 2024-08-16 11:39:50 +02:00
ansible_role_gitea/tasks/backup.yml

44 lines
1.3 KiB
YAML
Raw Normal View History

---
- name: Get service facts
ansible.builtin.service_facts:
- name: Backup block
2022-09-29 23:09:19 +02:00
when:
- ansible_facts.services["gitea.service"] is defined
- ansible_facts.services["gitea.service"].state == "running"
- gitea_active_version.stdout != gitea_version_target
block:
- name: Stopping gitea before upgrade
become: true
ansible.builtin.systemd:
2023-10-29 16:11:12 +01:00
name: 'gitea.service'
state: 'stopped'
when: ansible_service_mgr == "systemd"
- name: "Create backup directory"
become: true
ansible.builtin.file:
2023-10-29 16:11:12 +01:00
path: "{{ gitea_backup_location }}"
state: 'directory'
owner: "{{ gitea_user }}"
group: "{{ gitea_group }}"
mode: 'u=rwx,g=rx,o='
- name: Backing up gitea before upgrade
2022-01-23 14:08:46 +01:00
become: true
ansible.builtin.command:
2023-07-19 19:38:47 +02:00
cmd: "sudo -u {{ gitea_user }} {{ gitea_full_executable_path }} dump -c {{ gitea_configuration_path }}/gitea.ini"
chdir: "{{ gitea_backup_location }}"
2022-03-27 05:19:36 +02:00
changed_when: true
rescue:
- name: Starting gitea because backup failed
become: true
ansible.builtin.systemd:
2023-10-29 16:11:12 +01:00
name: 'gitea.service'
state: 'started'
when: ansible_service_mgr == "systemd"
2023-10-29 16:11:12 +01:00
- name: Print updateing error and cancel
ansible.builtin.fail:
msg: "failed to backup gitea"