54 lines
1.7 KiB
YAML

---
- name: Perform a ReaR backup
hosts: all
become: true
gather_facts: true
strategy: free
vars:
standalone_backup_success_path: "/var/log/IPE/IPU/el7to8"
standalone_backup_success_file: "{{ standalone_backup_success_path }}/standalone_rear_success"
tasks:
- name: Include the backup role
ansible.builtin.include_role:
name: ../roles/rear_backup
when:
- ansible_distribution_major_version >= '7'
- 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 and create success 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
- name: Create success file directory if not present
ansible.builtin.file:
path: "{{ standalone_backup_success_path }}"
state: directory
mode: "0755"
- name: Create backup success file
ansible.builtin.copy:
dest: "{{ standalone_backup_success_file }}"
content: "success\n"
mode: "0644"