A bit more for OpenWRT backups

This commit is contained in:
Bradley committed 2026-11-28 20:37:57 -05:00
1 parent 9e5e7e899c
commit 38d9e5a74d
1 file changed
+16 -1
+16 -1
View File
@@ -6,7 +6,8 @@
roles: roles:
- community.openwrt.init - community.openwrt.init
vars: vars:
backup_dir: "./backups/{{ inventory_hostname }}" backup_dir: "/tmp/backups/{{ inventory_hostname }}"
unarchive_where: "/tmp/openwrt"
remote_tmp_file: "/tmp/backup-{{ inventory_hostname }}-{{ lookup('pipe', 'date +%Y-%m-%d') }}.tar.gz" remote_tmp_file: "/tmp/backup-{{ inventory_hostname }}-{{ lookup('pipe', 'date +%Y-%m-%d') }}.tar.gz"
tasks: tasks:
- name: Ensure local backup directory exists - name: Ensure local backup directory exists
@@ -16,6 +17,13 @@
mode: '0755' mode: '0755'
delegate_to: localhost delegate_to: localhost
- name: Ensure unarchive_where directory exists
ansible.builtin.file:
path: "{{ unarchive_where }}"
state: directory
mode: '0755'
delegate_to: localhost
- name: Generate sysupgrade backup archive on OpenWrt - name: Generate sysupgrade backup archive on OpenWrt
community.openwrt.command: community.openwrt.command:
cmd: "sysupgrade -b {{ remote_tmp_file }}" cmd: "sysupgrade -b {{ remote_tmp_file }}"
@@ -36,3 +44,10 @@
community.openwrt.file: community.openwrt.file:
path: "{{ remote_tmp_file }}" path: "{{ remote_tmp_file }}"
state: absent state: absent
- name: Unarchive the file copied from OpenWRT
ansible.builtin.unarchive:
src: "{{ backup_dir }}/{{ remote_tmp_file | basename }}"
dest: "{{ unarchive_where }}"
remote_src: false
delegate_to: localhost