[Add backup full gitea + docker]

This commit is contained in:
2025-08-04 23:53:41 +02:00
parent 057167dd97
commit d6b06a38fb
2 changed files with 104 additions and 12 deletions

View File

@@ -1,23 +1,44 @@
- hosts: tower
vars:
dockerapps_path: /opt/dockerapps
gitea_conf: /appdata/gitea/gitea/
#backup: /backup/gitea
gitea_db: /appdata/gitea/gitea-db/gitea-db-pg.sql
# become: true
gather_facts: false
tasks:
- ansible.builtin.file:
path: "{{ dockerapps_path }}/backup/gitea"
state: directory
# mode: '0755'
#/opt/dockerapps/appdata/gitea/gitea/gitea-dump-*.zip
# - name: DUMP gitea conf
# community.docker.docker_container_exec:
# container: gitea
# command: gitea dump -c /data/gitea/conf/app.ini
# user: git
# chdir: /data
# register: result_gitea_conf
- name: DUMP gitea conf
community.docker.docker_container_exec:
container: gitea
command: gitea dump -c /data/gitea/conf/app.ini
user: git
chdir: /data
# - name: Print stdout
# ansible.builtin.debug:
# var: result_gitea_conf.stdout
- ansible.builtin.find:
paths: "{{ dockerapps_path }}{{ gitea_conf }}"
patterns: 'gitea-dump-*.zip'
register: result_gitea_conf
- name: Print stdout
ansible.builtin.debug:
var: result_gitea_conf
- name: Copy file with owner and permissions
ansible.builtin.copy:
src: "{{ item.path }}"
dest: "{{ dockerapps_path }}/backup/gitea/{{ item.path.split('/')[-1]}}"
loop: "{{ result_gitea_conf.files }}"
# owner: foo
# group: foo
# mode: '0644'
#! need root
@@ -30,10 +51,18 @@
# chdir: "{{ dockerapps_path }}"
register: result_gitea_db
- name: Print stdout
ansible.builtin.debug:
- ansible.builtin.debug:
var: result_gitea_db.stdout
- name: Copy file with owner and permissions
become: true
ansible.builtin.copy:
src: "{{ dockerapps_path }}{{ gitea_db }}"
dest: "{{ dockerapps_path }}/backup/gitea/{{ gitea_db.split('/')[-1] }}"
# owner: "{{ }}"
# group: foo
# mode: '0644'
# docker exec -u git -w /data/ gitea gitea dump -c /data/gitea/conf/app.ini
# mv /opt/dockerapps/appdata/gitea/gitea/gitea-dump-*.zip /opt/dockerapps/backup/