restic auto restore
This commit is contained in:
@@ -7,6 +7,11 @@
|
||||
vars_files:
|
||||
- ./vault.yaml
|
||||
|
||||
vars:
|
||||
restic_repo: "s3:http://misamisa.duckdns.org:9000/resticbackup"
|
||||
restore_target_path: "/apps"
|
||||
# restic_password_value: "Stored in vault"
|
||||
|
||||
tasks:
|
||||
- name: Set-debcache.yml - Setup apt proxy debcache
|
||||
ansible.builtin.import_tasks: ./setup-debcache.yaml
|
||||
@@ -25,16 +30,21 @@
|
||||
|
||||
- name: Check if app data directory exists
|
||||
stat:
|
||||
path: "/app/{{ ansible_hostname }}"
|
||||
register: app_stat
|
||||
path: "/app/"
|
||||
register: app_data
|
||||
|
||||
- name: Restore Wiapp datakmd Dir
|
||||
shell: |
|
||||
restic --password-file /home/restic/.resticpassword -r sftp:misamisa://home/restic/$(hostname) --target / restore latest
|
||||
- name: Restic restore app data Dir
|
||||
ansible.builtin.shell:
|
||||
cmd: "restic restore latest --tag {{ ansible_hostname }} --target {{ restore_target_path }}"
|
||||
environment:
|
||||
RESTIC_REPOSITORY: "{{ restic_repo }}"
|
||||
RESTIC_PASSWORD: "{{ restic_password_value }}"
|
||||
AWS_ACCESS_KEY_ID: "{{ aws_access_key_id }}"
|
||||
AWS_SECRET_ACCESS_KEY: "{{ aws_secret_access_key }}"
|
||||
args:
|
||||
chdir: /home/restic
|
||||
creates: "/app/{{ ansible_hostname }}"
|
||||
when: not app_stat.stat.exists or not app_stat.stat.isdir
|
||||
creates: "/app/data"
|
||||
|
||||
when: not app_data.stat.exists or not app_data.stat.isdir
|
||||
|
||||
- name: Reload systemd daemon
|
||||
systemd:
|
||||
|
||||
Reference in New Issue
Block a user