Skip to content

Commit

Permalink
copy backup file correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
SK1Y101 committed Aug 20, 2023
1 parent dcc8c04 commit e8fa52a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions restore.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -8,6 +17,7 @@
ansible.builtin.include_role:
name: common
tasks_from: restore
when: backup_file.stat.exists
become: true
gather_facts: true

Expand All @@ -17,6 +27,7 @@
ansible.builtin.include_role:
name: maas_postgres
tasks_from: restore
when: backup_file.stat.exists
become: true
gather_facts: true

Expand All @@ -29,5 +40,6 @@
ansible.builtin.file:
path: /tmp/maas_backup
state: absent
when: backup_file.stat.exists
become: true
gather_facts: true
2 changes: 1 addition & 1 deletion roles/common/tasks/backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion roles/common/tasks/restore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8fa52a

Please sign in to comment.