Skip to content
Commits on Source (2)
...@@ -23,7 +23,7 @@ restic: ...@@ -23,7 +23,7 @@ restic:
hour: '3' hour: '3'
stdin: stdin:
- database: 'mysqldump -u piwik -p$MYSQLPASSWORD 127.0.0.1' - database: 'mysqldump -u piwik -p$MYSQLPASSWORD 127.0.0.1'
filename: 'matomo.sql' filename: 'production.sql'
- name: 'local-mastodon' - name: 'local-mastodon'
repository: '/srv/backups/restic_mastodon-backup' repository: '/srv/backups/restic_mastodon-backup'
cron: cron:
......
...@@ -5,8 +5,10 @@ ...@@ -5,8 +5,10 @@
name: bzip2 name: bzip2
state: latest state: latest
register: apt_info register: apt_info
- name: Display stdout of apt - name: Display stdout of apt
debug: msg={{ apt_info.stdout.split('\n')[:-1] }} debug:
msg: "{{ apt_info.stdout.split('\n')[:-1] }}"
when: apt_info is changed when: apt_info is changed
- name: Get checksum for restic - name: Get checksum for restic
......
...@@ -17,41 +17,47 @@ ...@@ -17,41 +17,47 @@
- list_backups - list_backups
- name: Restore snapshot - name: Restore snapshot
block: block:
- name: Restore latest in tmp - name: Restore files
shell: "restic restore latest --target /tmp --path \"{{ item.1.folder }}\"" block:
when: snapshot_id is not defined and item.0.type == snapshot_type - name: Restore latest in tmp
loop: "{{ restic.backups|subelements('folders') }}" shell: "restic restore latest --target /tmp --path \"{{ item.1.folder }}\""
environment: when: snapshot_id is not defined and item.0.type == snapshot_type
RESTIC_PASSWORD: "{{ restic_password }}" loop: "{{ restic.backups|subelements('folders') }}"
- name: Restore snapshot_id in tmp environment:
shell: "restic restore -r {{ item.repository }} {{ snapshot_id }} --target /tmp" RESTIC_PASSWORD: "{{ restic_password }}"
when: snapshot_id is defined and item.type == snapshot_type - name: Restore snapshot_id in tmp
loop: "{{ restic.backups }}" shell: "restic restore -r {{ item.repository }} {{ snapshot_id }} --target /tmp"
environment: when: snapshot_id is defined and item.type == snapshot_type
RESTIC_PASSWORD: "{{ restic_password }}" loop: "{{ restic.backups }}"
- name: backup before instance deletion of the folder environment:
command: "bash /root/scripts/restic_backup_{{ snapshot_type }}-{{ app_instance_id }}.sh" RESTIC_PASSWORD: "{{ restic_password }}"
- name: Restore /tmp/{{ item.folder }} - name: backup before instance deletion of the folder
copy: command: "bash /root/scripts/restic_backup_{{ snapshot_type }}-{{ app_instance_id }}.sh"
remote_src: true - name: Restore /tmp/{{ item.folder }}
force: yes copy:
src: "/tmp/{{ snapshot_folder }}" remote_src: true
dest: "{{ snapshot_folder }}/.." force: yes
owner: "{{ app_user }}" src: "/tmp/{{ snapshot_folder }}"
group: "{{ app_group }}" dest: "{{ snapshot_folder }}/.."
when: snapshot_id is defined and item.type == snapshot_type owner: "{{ app_user }}"
loop: "{{ restic.backups }}" group: "{{ app_group }}"
when: snapshot_id is defined and item.type == snapshot_type
- name: Restore /tmp/{{ item.folder }} loop: "{{ restic.backups }}"
copy: - name: Restore /tmp/{{ item.folder }}
remote_src: true copy:
force: yes remote_src: true
src: "/tmp/{{ item.1.folder }}" force: yes
dest: "{{ item.1.folder }}/.." src: "/tmp/{{ item.1.folder }}"
owner: "{{ app_user }}" dest: "{{ item.1.folder }}/.."
group: "{{ app_group }}" owner: "{{ app_user }}"
when: snapshot_id is not defined and item.0.type == snapshot_type group: "{{ app_group }}"
loop: "{{ restic.backups|subelements('folders') }}" when: snapshot_id is not defined and item.0.type == snapshot_type
loop: "{{ restic.backups|subelements('folders') }}"
- name: Restore db if needed
block:
# Database
- name: Restore db snapshot if needed
shell: "restic -r {{ item.repository }} dump {{ snapshot_id }} {{ item.filename }}.sql | mysql"
when: snapshot_id is not defined and item.0.type == snapshot_type and data_type = mariadb
loop: "{{ restic.backups }}"
when: snapshots_list is not defined when: snapshots_list is not defined
tags:
- restore_backup
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
- import_tasks: uninstall.yml - import_tasks: uninstall.yml
when: app_run == 'uninstall' when: app_run == 'uninstall'
- block: - name: Set up service
block:
- name: "stop service {{ app_service }}" - name: "stop service {{ app_service }}"
systemd: systemd:
......