Variable cleanup, configuration backup, log archive post-backup

This commit is contained in:
Chris Hammer 2025-02-28 15:29:34 -05:00
parent cd16954ae5
commit e11710f504
5 changed files with 40 additions and 4 deletions

View File

@ -13,3 +13,25 @@
when: when:
- ansible_distribution_major_version >= '7' - ansible_distribution_major_version >= '7'
- not rear_backup_skip | default(false) | bool - not rear_backup_skip | default(false) | bool
- name: Verify ReaR backup log is present
ansible.builtin.stat:
path: "/var/log/rear/rear-{{ ansible_hostname }}.log"
register: rear_backup_log_stat
- name: Backup ReaR log file
when:
- rear_backup_log_stat['stat']['exists']
block:
- name: Copy ReaR log file to backup location
ansible.builtin.copy:
src: "/var/log/rear/rear-{{ ansible_hostname }}.log"
dest: "/var/log/rear-{{ ansible_hostname }}-{{ '%Y-%m-%d' | strftime(rear_backup_log_stat['stat']['mtime']) }}.log"
mode: "0644"
backup: true
remote_src: true
- name: Remove ReaR log file
ansible.builtin.file:
path: "/var/log/rear/rear-{{ ansible_hostname }}.log"
state: absent

View File

@ -1,3 +1,3 @@
--- ---
rear_nfs_export_share: "/backups/standalone" rear_nfs_export_share: "/backups/standalone"
rear_nfs_export_fsid: 0 rear_nfs_export_fsid: 10

View File

@ -81,3 +81,17 @@
ansible.builtin.fail: ansible.builtin.fail:
msg: "ReaR backup has failed. Please review the logs for any errors, and try again." msg: "ReaR backup has failed. Please review the logs for any errors, and try again."
- name: Verify ReaR configuration is present
ansible.builtin.stat:
path: /etc/rear
register: rear_config_stat
- name: Create backup of ReaR configuration files
community.general.archive:
path: /etc/rear
dest: /root/etc-rear-backup.tar.gz
format: gz
force_archive: true
mode: "0600"
when:
- rear_config_stat['stat']['exists'] | bool

View File

@ -3,9 +3,9 @@
############################################## ##############################################
OUTPUT=ISO OUTPUT=ISO
OUTPUT_URL=nfs://{{ nfs_srv }}{{ rear_nfs_export_share }} OUTPUT_URL=nfs://{{ nfs_srv }}{{ rear_nfs_backup_share }}
BACKUP=NETFS BACKUP=NETFS
BACKUP_URL=nfs://{{ nfs_srv }}{{ rear_nfs_export_share }} BACKUP_URL=nfs://{{ nfs_srv }}{{ rear_nfs_backup_share }}
# SSH_ROOT_PASSWORD="bob" # SSH_ROOT_PASSWORD="bob"
USE_STATIC_NETWORKING=yes USE_STATIC_NETWORKING=yes
CLONES_ALL_USERS_GROUPS=yes CLONES_ALL_USERS_GROUPS=yes

View File

@ -6,7 +6,7 @@ nfs_np:
nfs_prod: nfs_prod:
- 10.10.42.180 - 10.10.42.180
rear_nfs_export_share: /backups/standalone rear_nfs_backup_share: /backups/standalone
rear_grub_label: 'Relax-and-Recover *** RESTORES RHEL7 ***' rear_grub_label: 'Relax-and-Recover *** RESTORES RHEL7 ***'
rear_grub_conf: /etc/grub.d/45_rear rear_grub_conf: /etc/grub.d/45_rear