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