Backup und Restore, falls der Server nicht wieder hoch kommt
This commit is contained in:
parent
f2bbe10aa2
commit
8d30bb6eb6
@ -41,6 +41,24 @@
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: Backup Files
|
||||
block:
|
||||
- name: Stop Gitea for Backup
|
||||
community.docker.docker_compose:
|
||||
project_src: /opt/gitea
|
||||
state: present
|
||||
stopped: true
|
||||
|
||||
- name: Backup Gitea Directory
|
||||
ansible.builtin.copy:
|
||||
src: /opt/gitea
|
||||
dest: "/opt/gitea.backup@{{ ansible_date_time.iso8601 }}"
|
||||
remote_src: true
|
||||
directory_mode: true
|
||||
register: backup
|
||||
|
||||
- name: Apply Changes
|
||||
block:
|
||||
- name: Upload Environment File
|
||||
ansible.builtin.template:
|
||||
src: environment.env.j2
|
||||
@ -57,7 +75,7 @@
|
||||
mode: 0600
|
||||
register: gitea_container
|
||||
|
||||
- name: Create / Recreate Gitea container
|
||||
- name: Create / Recreate Gitea
|
||||
community.docker.docker_compose:
|
||||
project_src: /opt/gitea
|
||||
state: present
|
||||
@ -69,5 +87,32 @@
|
||||
url: "https://{{ gitea.hostname }}.{{ gitea.domain }}"
|
||||
register: _result
|
||||
until: _result.status == 200
|
||||
retries: 60
|
||||
delay: 10
|
||||
retries: 30
|
||||
delay: 2
|
||||
|
||||
rescue:
|
||||
- name: Stop Gitea for Backup
|
||||
community.docker.docker_compose:
|
||||
project_src: /opt/gitea
|
||||
state: present
|
||||
stopped: true
|
||||
|
||||
- name: Restore Gitea Directory from Backup
|
||||
ansible.builtin.copy:
|
||||
src: "{{ backup.dest }}"
|
||||
dest: "{{ backup.src }}"
|
||||
remote_src: true
|
||||
|
||||
- name: Create / Recreate Gitea
|
||||
community.docker.docker_compose:
|
||||
project_src: /opt/gitea
|
||||
state: present
|
||||
restarted: true
|
||||
always:
|
||||
- name: Check if {{ gitea.hostname }}.{{ gitea.domain }} is available and returning status 200
|
||||
ansible.builtin.uri:
|
||||
url: "https://{{ gitea.hostname }}.{{ gitea.domain }}"
|
||||
register: _result
|
||||
until: _result.status == 200
|
||||
retries: 30
|
||||
delay: 2
|
||||
|
Loading…
Reference in New Issue
Block a user