68 lines
2.3 KiB
YAML
68 lines
2.3 KiB
YAML
---
|
|
- name: Perform a ReaR backup
|
|
hosts: all
|
|
become: true
|
|
gather_facts: true
|
|
strategy: free
|
|
|
|
vars:
|
|
standalone_backup_success_path: "/var/IPE/IPU/el7to8"
|
|
standalone_backup_success_file: "{{ standalone_backup_success_path }}/standalone_rear_success"
|
|
|
|
|
|
tasks:
|
|
- name: Check for backup success file
|
|
ansible.builtin.stat:
|
|
path: "{{ standalone_backup_success_file }}"
|
|
register: standalone_backup_success
|
|
|
|
- name: End if backup for Bigboot already exists
|
|
ansible.builtin.meta: end_host
|
|
when:
|
|
- standalone_backup_success['stat']['exists'] | bool
|
|
- not rear_force_backup | default(false) | bool
|
|
|
|
|
|
- name: Perform ReaR Backup and write success log
|
|
when:
|
|
- ansible_distribution_major_version >= '7'
|
|
- not rear_backup_skip | default(false) | bool
|
|
block:
|
|
- name: Include the backup role
|
|
ansible.builtin.include_role:
|
|
name: ../roles/rear_backup
|
|
|
|
- name: Confirm 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"
|