diff --git a/restore.yaml b/restore.yaml index 704e62a..d6553aa 100644 --- a/restore.yaml +++ b/restore.yaml @@ -1,4 +1,13 @@ --- +- hosts: all + tasks: + - name: Check backup file exists for host. + stat: + path: "{{ maas_backup_download_path }}{{ maas_backup_file }}" + delegate_to: localhost + become: false + register: backup_file + - hosts: - maas_postgres - maas_region_controller @@ -8,6 +17,7 @@ ansible.builtin.include_role: name: common tasks_from: restore + when: backup_file.stat.exists become: true gather_facts: true @@ -17,6 +27,7 @@ ansible.builtin.include_role: name: maas_postgres tasks_from: restore + when: backup_file.stat.exists become: true gather_facts: true @@ -29,5 +40,6 @@ ansible.builtin.file: path: /tmp/maas_backup state: absent + when: backup_file.stat.exists become: true gather_facts: true diff --git a/roles/common/tasks/backup.yaml b/roles/common/tasks/backup.yaml index 09de49d..f99e964 100644 --- a/roles/common/tasks/backup.yaml +++ b/roles/common/tasks/backup.yaml @@ -19,7 +19,7 @@ # ansible.builtin.fetch has the ability to be oom killed on large files, so we're using scp instead - name: Download Backup - ansible.builtin.command: scp {{ ansible_user }}@{{ inventory_hostname }}:{{ maas_backup_dest_path }} {{ maas_backup_download_path }} + ansible.builtin.command: scp {{ ansible_user }}@{{ inventory_hostname }}:{{ maas_backup_dest_path }} {{ maas_backup_download_path }}{{ maas_backup_file }} delegate_to: localhost become: false # don't need sudo locally changed_when: false diff --git a/roles/common/tasks/restore.yaml b/roles/common/tasks/restore.yaml index 42781e6..bad2ffd 100644 --- a/roles/common/tasks/restore.yaml +++ b/roles/common/tasks/restore.yaml @@ -9,7 +9,7 @@ - name: Unpack Backup Archive ansible.builtin.unarchive: - src: "{{ maas_backup_file }}" + src: "{{ maas_backup_download_path }}{{ maas_backup_file }}" dest: /tmp/maas_backup/ - name: Stop Region Controller