From 129674be94a441e1568b79f09dfaa3f069765924 Mon Sep 17 00:00:00 2001
From: L3D <l3d@c3woc.de>
Date: Wed, 4 May 2022 20:42:23 +0200
Subject: [PATCH] starting gitea if backup failed

Resolving https://github.com/roles-ansible/ansible_role_gitea/issues/78
---
 tasks/backup.yml | 11 +++++++++++
 vars/main.yml    |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/tasks/backup.yml b/tasks/backup.yml
index 01e0a74..66b3518 100644
--- a/tasks/backup.yml
+++ b/tasks/backup.yml
@@ -27,6 +27,17 @@
         cmd: "sudo -u {{ gitea_user }} /usr/local/bin/gitea dump -c /etc/gitea/gitea.ini"
         chdir: "{{ gitea_backup_location }}"
       changed_when: true
+  rescue:
+    - name: Starting gitea because backup failed
+      become: true
+      ansible.builtin.systemd:
+        name: gitea
+        state: stopped
+      when: ansible_service_mgr == "systemd"
+
+    - name: print updateing error
+      ansible.builtin.debug:
+        msg: "failed to backup gitea"
   when:
     - ansible_facts.services["gitea.service"] is defined
     - ansible_facts.services["gitea.service"].state == "running"
diff --git a/vars/main.yml b/vars/main.yml
index 13d2e31..33efc57 100644
--- a/vars/main.yml
+++ b/vars/main.yml
@@ -56,5 +56,5 @@ transfer_custom_footer:
     - 'files/gitea_footer/extra_links_footer.tmpl'
     - 'files/extra_links_footer.tmpl'
 
-playbook_version_number: 36  # should be int
+playbook_version_number: 37  # should be int
 playbook_version_path: 'do1jlr.gitea.version'