ReaR restore initial

This commit is contained in:
2025-03-06 01:07:40 -05:00
parent 1cbc9699d8
commit 13ff9b24d6
8 changed files with 95 additions and 217 deletions

View File

@ -9,80 +9,6 @@
ansible.builtin.import_role:
name: rhc.rear.rear_vars
- name: Check if ReaR restore was already completed
ansible.builtin.find:
paths:
- /var/tmp
patterns:
- "rear_restore.{{ rear_backup_workflow }}*"
register: rear_restore_file
- name: Check for ReaR restore
when:
- rear_restore_file['files'] | length > 0
block:
- name: Check for ReaR restore
ansible.builtin.debug:
msg: "ReaR restore was already completed - {{ rear_restore_file['files'] | json_query('[].path') | string }}"
# - name: End host for servers that already completed a ReaR restore
# ansible.builtin.meta: end_host
- name: Check if configuration backup exists
ansible.builtin.stat:
path: "/root/etc-rear-backup-{{ rear_backup_workflow }}.tar.gz"
register: rear_config_backup_stat
- name: Create tmpdir and extract archive
when:
- rear_config_backup_stat['stat']['exists'] | bool
block:
- name: Create tmpdir
ansible.builtin.file:
path: "{{ rear_restore_tmpdir }}"
state: directory
mode: "0755"
- name: Extract archive contents
ansible.builtin.unarchive:
remote_src: true
src: "/root/etc-rear-backup-{{ rear_backup_workflow }}.tar.gz"
dest: "{{ rear_restore_tmpdir }}"
- name: Copy local.cfg from backup into /etc/rear
ansible.builtin.copy:
src: "{{ rear_restore_tmpdir }}/rear/local.conf"
dest: /etc/rear/local.conf
remote_src: true
mode: "0600"
# - name: Rebuild ReaR initrd
# ansible.builtin.command:
# cmd: rear -d -v mkrescue
# register: rear_initrd_cmd
- name: Cleanup leftover artifacts
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "{{ rear_backup_success_file_path }}/{{ rear_backup_workflow }}_rear_success"
- "{{ rear_restore_tmpdir }}"
- name: Create file for ReaR restore success
ansible.builtin.file:
path: "/var/tmp/rear_restore.{{ rear_backup_workflow }}.{{ ansible_date_time.iso8601_basic }}"
state: touch
mode: "0664"
# - name: Import rear_vars role
# ansible.builtin.import_role:
# name: rhc.rear.rear_vars
# - name: Configure ReaR local.conf file
# ansible.builtin.include_role:
# name: rhc.rear.rear_local_cfg
# - name: Perform ReaR restore
# ansible.builtin.include_role:
# name: rhc.rear.rear_restore
- name: Include ReaR restore role
ansible.builtin.include_role:
name: rhc.rear.rear_restore