More backup stuff

This commit is contained in:
2025-08-20 17:45:57 -04:00
parent 16e9c32e41
commit 846496d618
2 changed files with 23 additions and 0 deletions

View File

@@ -82,6 +82,27 @@
dest: "{{ backup_location }}/{{ inventory_hostname }}_{{ now().strftime('%Y%m%d%H%M%S') }}.xml"
changed_when: false
no_log: "{{ pfsense_backup_disable_logging | default(false) }}"
- name: Find all PFSense backups for the current host
ansible.builtin.find:
paths: "{{ backup_location }}"
patterns: "{{ inventory_hostname }}*"
register: all_pfsense_backups
- name: If too many backups kept
when: all_pfsense_backups | length > backup_number_to_keep
block:
- name: Get the oldest file paths
ansible.builtin.set_fact:
oldest_file_paths: >-
{{ (all_pfsense_backups.files | sort(attribute='mtime'))[:all_pfsense_backups.files | length - backup_number_to_keep] |
map(attribute=path) | list }}
- name: Remove the files
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop: "{{ oldest_file_paths }}"
- name: Docker Infrastructure Compose Backups
hosts: docker_nodes