[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 - hosts: tower
vars: vars:
dockerapps_path: /opt/dockerapps dockerapps_path: /opt/dockerapps
gitea_conf: /appdata/gitea/gitea/
#backup: /backup/gitea
gitea_db: /appdata/gitea/gitea-db/gitea-db-pg.sql
# become: true # become: true
gather_facts: false gather_facts: false
tasks: tasks:
- ansible.builtin.file:
path: "{{ dockerapps_path }}/backup/gitea"
state: directory
# mode: '0755'
#/opt/dockerapps/appdata/gitea/gitea/gitea-dump-*.zip #/opt/dockerapps/appdata/gitea/gitea/gitea-dump-*.zip
# - name: DUMP gitea conf - name: DUMP gitea conf
# community.docker.docker_container_exec: community.docker.docker_container_exec:
# container: gitea container: gitea
# command: gitea dump -c /data/gitea/conf/app.ini command: gitea dump -c /data/gitea/conf/app.ini
# user: git user: git
# chdir: /data chdir: /data
# register: result_gitea_conf
# - name: Print stdout - ansible.builtin.find:
# ansible.builtin.debug: paths: "{{ dockerapps_path }}{{ gitea_conf }}"
# var: result_gitea_conf.stdout 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 #! need root
@@ -30,10 +51,18 @@
# chdir: "{{ dockerapps_path }}" # chdir: "{{ dockerapps_path }}"
register: result_gitea_db register: result_gitea_db
- name: Print stdout - ansible.builtin.debug:
ansible.builtin.debug:
var: result_gitea_db.stdout 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 # 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/ # mv /opt/dockerapps/appdata/gitea/gitea/gitea-dump-*.zip /opt/dockerapps/backup/

View File

@@ -3,6 +3,9 @@
# become: true # become: true
gather_facts: false gather_facts: false
vars: vars:
dockerapps_path: /opt/dockerapps
gitea_conf: /appdata/gitea/gitea/
gitea_db: /appdata/gitea/gitea-db/gitea-db-pg.sql
user: sgratias user: sgratias
user_mail: stephane.gratiasquiquandon@gmail.com user_mail: stephane.gratiasquiquandon@gmail.com
token: !vault | token: !vault |
@@ -15,6 +18,9 @@
3565333032326133326232326633386332633639373862313463 3565333032326133326232326633386332633639373862313463
tasks: tasks:
############
###! DOCKER COMPOSE FILE
############
# - debug: # - debug:
# msg: "test ok" # msg: "test ok"
@@ -109,6 +115,63 @@
delegate_to: localhost delegate_to: localhost
#############
#! GITEA
############
- 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
- 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
# root@scaleway:/opt/dockerapps/appdata/gitea/gitea-db/gitea-db-pg.sql
- name: PG_DUMP postgresql db
community.docker.docker_container_exec:
container: gitea-db
command: pg_dump -U root gitea -f /var/lib/postgresql/data/gitea-db-pg.sql
# chdir: "{{ dockerapps_path }}"
register: result_gitea_db
- 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] }}"
# curl -u "$username:$password" -H "Title: HTTPS Certificats" -H "ta:closed_lock_with_key" -d "*.jingoh.fr Less than 20 days" https://alert.jingoh.fr/scaleway # curl -u "$username:$password" -H "Title: HTTPS Certificats" -H "ta:closed_lock_with_key" -d "*.jingoh.fr Less than 20 days" https://alert.jingoh.fr/scaleway
# when: cert.not_after - ansible_date_time.iso8601_basic > # when: cert.not_after - ansible_date_time.iso8601_basic >