67 lines
1.9 KiB
YAML
67 lines
1.9 KiB
YAML
---
|
|
- name: Create backup directory on ops server
|
|
file:
|
|
path: "{{ backup_dest_dir }}"
|
|
state: directory
|
|
mode: '0755'
|
|
owner: asxpi
|
|
group: asxpi
|
|
delegate_to: asxpio-ops
|
|
become: true
|
|
|
|
- name: Find existing Forgejo dump files on old server
|
|
find:
|
|
paths: /srv/gitea
|
|
patterns: "*.zip"
|
|
file_type: file
|
|
register: existing_dumps
|
|
|
|
- name: Create backup archive from old server
|
|
archive:
|
|
path:
|
|
- /srv/gitea/gitea.db
|
|
- /srv/gitea/data/avatars
|
|
- /srv/gitea/data/repo-avatars
|
|
- /srv/gitea/data/repo-archive
|
|
- /srv/gitea/data/attachments
|
|
- /srv/gitea/data/gitea-repositories
|
|
dest: /tmp/forgejo-full-backup-{{ ansible_date_time.date }}.tar.gz
|
|
format: gz
|
|
become: true
|
|
|
|
- name: Display found backup files
|
|
debug:
|
|
msg: |
|
|
Found {{ existing_dumps.files | length }} dump files
|
|
Created full backup archive: /tmp/forgejo-full-backup-{{ ansible_date_time.date }}.tar.gz
|
|
|
|
- name: Fetch dump file to ops server (if exists)
|
|
synchronize:
|
|
mode: pull
|
|
src: "{{ (existing_dumps.files | sort(attribute='mtime', reverse=true) | first).path }}"
|
|
dest: /opt/forgejo-backup/
|
|
delegate_to: asxpio-ops
|
|
when: existing_dumps.files | length > 0
|
|
ignore_errors: true
|
|
|
|
- name: Fetch full backup archive to ops server
|
|
synchronize:
|
|
mode: pull
|
|
src: /tmp/forgejo-full-backup-{{ ansible_date_time.date }}.tar.gz
|
|
dest: /opt/forgejo-backup/
|
|
delegate_to: asxpio-ops
|
|
become: true
|
|
|
|
- name: Display backup location
|
|
debug:
|
|
msg: |
|
|
Backup files transferred to asxpio-ops:/opt/forgejo-backup/
|
|
|
|
Files:
|
|
- forgejo-full-backup-{{ ansible_date_time.date }}.tar.gz (complete backup)
|
|
{% if existing_dumps.files | length > 0 %}
|
|
- {{ (existing_dumps.files | sort(attribute='mtime', reverse=true) | first).path | basename }} (dump file)
|
|
{% endif %}
|
|
|
|
Next step: Run restore playbook
|
|
ansible-playbook playbooks/restore-forgejo.yaml
|