2025-07-10 21:24:28 -06:00

27 lines
683 B
YAML

---
- name: Copy /etc/ backup script to PVE node
template:
src: backup_pve_config.sh.j2
dest: /home/xbazzi/backup_pve.sh
mode: '0755'
- name: Run backup script
shell: /home/xbazzi/backup_pve.sh
- name: Find most recent backup directory
shell: "ls -td /home/xbazzi/pve_backup_* | head -1"
register: latest_backup_dir
changed_when: false
- name: Archive backup folder
archive:
path: "{{ latest_backup_dir.stdout }}"
dest: "{{ latest_backup_dir.stdout }}.tar.gz"
format: gz
- name: Fetch backup archive to control machine
fetch:
src: "{{ latest_backup_dir.stdout }}.tar.gz"
dest: "backups/{{ inventory_hostname }}.tar.gz"
flat: yes