Don't use date in gitea dump pushing, use latest present dump on the server instead
This commit is contained in:
parent
d4c2cc1e75
commit
90814de597
1 changed files with 18 additions and 18 deletions
|
@ -1,33 +1,33 @@
|
|||
---
|
||||
- name: Set today's string for zipfile name
|
||||
ansible.builtin.set_fact:
|
||||
today: "{{ ansible_date_time.year }}{{ ansible_date_time.month }}{{ ansible_date_time.day }}"
|
||||
|
||||
- name: Ask to push latest gitea_dump zipfile
|
||||
ansible.builtin.pause:
|
||||
prompt: "Local path to latest gitea dump, so we can push it [leave empty to not push]"
|
||||
prompt: "Local path to gitea dump, so we can push it [leave empty to not push]"
|
||||
echo: true
|
||||
register: latest_gitea_dump_path
|
||||
register: user_gitea_dump_path
|
||||
|
||||
- name: Make sure the filename makes sense
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "{{ latest_gitea_dump_path.user_input | basename }} == gitea-dump-{{ today }}.zip"
|
||||
when: latest_gitea_dump_path.user_input != ''
|
||||
|
||||
- name: Push latest gitea_dump zipfile
|
||||
- name: Push latest gitea dump zipfile
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
src: "{{ latest_gitea_dump_path.user_input }}"
|
||||
dest: "/var/lib/gitea/gitea-dumps/gitea-dump-{{ today }}.zip"
|
||||
src: "{{ user_gitea_dump_path.user_input }}"
|
||||
dest: "/var/lib/gitea/gitea-dumps/{{ user_gitea_dump_path.user_input | basename }}"
|
||||
owner: git
|
||||
group: git
|
||||
mode: 0640
|
||||
when: latest_gitea_dump_path.user_input != ''
|
||||
when: user_gitea_dump_path.user_input != ''
|
||||
|
||||
- name: Deploy repos
|
||||
- name: Find all gitea dumps on the server
|
||||
become: true
|
||||
ansible.builtin.find:
|
||||
paths: "/var/lib/gitea/gitea-dumps/"
|
||||
register: all_gitea_dumps
|
||||
|
||||
- name: Find latest gitea dump on the server
|
||||
ansible.builtin.set_fact:
|
||||
latest_gitea_dump: "{{ all_gitea_dumps.files | sort(attribute='mtime') | last }}"
|
||||
|
||||
- name: Deploy repos from latest gitea dump
|
||||
become: true
|
||||
become_user: git
|
||||
ansible.builtin.command:
|
||||
cmd: "/var/lib/gitea/gitea_backup.sh restore /var/lib/gitea/gitea-dumps/gitea-dump-{{ today }}.zip"
|
||||
cmd: "/var/lib/gitea/gitea_backup.sh restore {{ latest_gitea_dump.path }}"
|
||||
creates: /var/lib/gitea/gitea-repositories # when this dir exists, the command won't run, so we don't overwrite existing repos
|
||||
|
|
Loading…
Reference in a new issue