restic auto restore

This commit is contained in:
Ryan Toler
2026-03-13 04:02:20 +00:00
parent 0a444269b9
commit 6704565217
2 changed files with 136 additions and 119 deletions

View File

@@ -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: