From a291e78db6d3b9d37a893824aa552a918f694a59 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Sun, 21 May 2023 19:56:51 +0200 Subject: [PATCH] [AUTO-RESTORE] Add all --- group_vars/all.yml | 18 ++++++++- roles/cloud/tasks/restore.yml | 13 ++++--- roles/home_assistant/tasks/main.yml | 6 ++- roles/home_assistant/tasks/restore.yml | 40 ++++++++++++++++++++ roles/matrix/tasks/main.yml | 6 ++- roles/matrix/tasks/restore.yml | 52 ++++++++++++++++++++++++++ roles/n8n/tasks/main.yml | 6 ++- roles/n8n/tasks/restore.yml | 43 +++++++++++++++++++++ roles/protonmail/tasks/main.yml | 6 ++- roles/protonmail/tasks/restore.yml | 40 ++++++++++++++++++++ roles/traefik/tasks/main.yml | 6 ++- roles/traefik/tasks/restore.yml | 43 +++++++++++++++++++++ 12 files changed, 267 insertions(+), 12 deletions(-) create mode 100644 roles/home_assistant/tasks/restore.yml create mode 100644 roles/matrix/tasks/restore.yml create mode 100644 roles/n8n/tasks/restore.yml create mode 100644 roles/protonmail/tasks/restore.yml create mode 100644 roles/traefik/tasks/restore.yml diff --git a/group_vars/all.yml b/group_vars/all.yml index 964a4f4..6d7cab5 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -19,4 +19,20 @@ protonmail: restore: cloud: nextcloud_archive: false - db_archive: false \ No newline at end of file + db_archive: false + home_assistant: + home_assistant_config_archive: false + matrix: + db_archive: false + matrix_archive: false + mautrix_facebook_archive: false + mautrix_instagram_archive: false + mautrix_discord_archive: false + n8n: + n8n_archive: false + db_archive: false + protonmail: + protonmail_archive: false + traefik: + prometheus_archive: false + grafana_archive: false diff --git a/roles/cloud/tasks/restore.yml b/roles/cloud/tasks/restore.yml index 0d74cfe..26909bd 100644 --- a/roles/cloud/tasks/restore.yml +++ b/roles/cloud/tasks/restore.yml @@ -5,8 +5,8 @@ src: "{{ item.src }}" dest: "{{ item.dest }}" loop: - - { src: '{{ restore.cloud.nextcloud_archive }}', dest: 'nextcloud_archive.tar.gz' } - - { src: '{{ restore.cloud.db_archive }}', dest: 'db_archive.tar.gz' } + - { src: '{{ restore.cloud.nextcloud_archive }}', dest: 'cloud_nextcloud.tar.gz' } + - { src: '{{ restore.cloud.db_archive }}', dest: 'cloud_db.tar.gz' } - name: Stop nextcloud container community.docker.docker_compose: @@ -19,12 +19,13 @@ name: volume_restore image: volume_restore:latest auto_remove: yes + tty: true volumes: - "{{ item.path }}:/backup/archive.tar.gz" - "{{ item.volume }}:/backup/dest" loop: - - { path: './nextcloud_archive.tar.gz', volume: 'cloud_nextcloud' } - - { path: './db_archive.tar.gz', volume: 'cloud_db' } + - { path: './cloud_nextcloud.tar.gz', volume: 'cloud_nextcloud' } + - { path: './cloud_db.tar.gz', volume: 'cloud_db' } become: true - name: Start nextcloud container @@ -38,5 +39,5 @@ path: "{{ item.path }}" state: absent loop: - - { path: 'nextcloud_archive.tar.gz' } - - { path: 'db_archive.tar.gz' } \ No newline at end of file + - { path: 'cloud_nextcloud.tar.gz' } + - { path: 'cloud_db.tar.gz' } \ No newline at end of file diff --git a/roles/home_assistant/tasks/main.yml b/roles/home_assistant/tasks/main.yml index 3f670ac..d0a3a57 100644 --- a/roles/home_assistant/tasks/main.yml +++ b/roles/home_assistant/tasks/main.yml @@ -1,4 +1,8 @@ --- - ansible.builtin.import_tasks: base.yml - name: base \ No newline at end of file + name: base + +- ansible.builtin.import_tasks: restore.yml + name: restore + when: restore.home_assistant.home_assistant_config_archive \ No newline at end of file diff --git a/roles/home_assistant/tasks/restore.yml b/roles/home_assistant/tasks/restore.yml new file mode 100644 index 0000000..9ce998a --- /dev/null +++ b/roles/home_assistant/tasks/restore.yml @@ -0,0 +1,40 @@ +--- + +- name: Copy archives + ansible.builtin.copy: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + loop: + - { src: '{{ restore.home_assistant.home_assistant_config_archive }}', dest: 'home_assistant_home_assistant_config.tar.gz' } + +- name: Stop nextcloud container + community.docker.docker_compose: + project_src: home_assistant + state: absent + become: true + +- name: Restore backup + community.docker.docker_container: + name: volume_restore + image: volume_restore:latest + auto_remove: yes + tty: true + volumes: + - "{{ item.path }}:/backup/archive.tar.gz" + - "{{ item.volume }}:/backup/dest" + loop: + - { path: './home_assistant_home_assistant_config.tar.gz', volume: 'home_assistant_home_assistant_config' } + become: true + +- name: Start nextcloud container + community.docker.docker_compose: + project_src: home_assistant + state: present + become: true + +- name: Remove archive + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: + - { path: 'home_assistant_home_assistant_config.tar.gz' } \ No newline at end of file diff --git a/roles/matrix/tasks/main.yml b/roles/matrix/tasks/main.yml index 3f670ac..fa0b2bb 100644 --- a/roles/matrix/tasks/main.yml +++ b/roles/matrix/tasks/main.yml @@ -1,4 +1,8 @@ --- - ansible.builtin.import_tasks: base.yml - name: base \ No newline at end of file + name: base + +- ansible.builtin.import_tasks: restore.yml + name: restore + when: restore.matrix.db_archive and restore.matrix.matrix_archive and restore.matrix.mautrix_facebook_archive and restore.matrix.mautrix_instagram_archive and restore.matrix.mautrix_discord_archive \ No newline at end of file diff --git a/roles/matrix/tasks/restore.yml b/roles/matrix/tasks/restore.yml new file mode 100644 index 0000000..17b6cbb --- /dev/null +++ b/roles/matrix/tasks/restore.yml @@ -0,0 +1,52 @@ +--- + +- name: Copy archives + ansible.builtin.copy: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + loop: + - { src: '{{ restore.matrix.db_archive }}', dest: 'matrix_db.tar.gz' } + - { src: '{{ restore.matrix.matrix_archive }}', dest: 'matrix_matrix.tar.gz' } + - { src: '{{ restore.matrix.mautrix_facebook_archive }}', dest: 'matrix_mautrix_facebook.tar.gz' } + - { src: '{{ restore.matrix.mautrix_instagram_archive }}', dest: 'matrix_mautrix_instagram.tar.gz' } + - { src: '{{ restore.matrix.mautrix_discord_archive }}', dest: 'matrix_mautrix_discord.tar.gz' } + +- name: Stop nextcloud container + community.docker.docker_compose: + project_src: matrix + state: absent + become: true + +- name: Restore backup + community.docker.docker_container: + name: volume_restore + image: volume_restore:latest + auto_remove: yes + tty: true + volumes: + - "{{ item.path }}:/backup/archive.tar.gz" + - "{{ item.volume }}:/backup/dest" + loop: + - { path: './matrix_db.tar.gz', volume: 'matrix_db' } + - { path: './matrix_matrix.tar.gz', volume: 'matrix_matrix' } + - { path: './matrix_mautrix_facebook.tar.gz', volume: 'matrix_mautrix_facebook' } + - { path: './matrix_mautrix_instagram.tar.gz', volume: 'matrix_mautrix_instagram' } + - { path: './matrix_mautrix_discord.tar.gz', volume: 'matrix_mautrix_discord' } + become: true + +- name: Start nextcloud container + community.docker.docker_compose: + project_src: matrix + state: present + become: true + +- name: Remove archive + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: + - { path: 'matrix_db.tar.gz' } + - { path: 'matrix_matrix.tar.gz' } + - { path: 'matrix_mautrix_facebook.tar.gz' } + - { path: 'matrix_mautrix_instagram.tar.gz' } + - { path: 'matrix_mautrix_discord.tar.gz' } \ No newline at end of file diff --git a/roles/n8n/tasks/main.yml b/roles/n8n/tasks/main.yml index 3f670ac..b26c897 100644 --- a/roles/n8n/tasks/main.yml +++ b/roles/n8n/tasks/main.yml @@ -1,4 +1,8 @@ --- - ansible.builtin.import_tasks: base.yml - name: base \ No newline at end of file + name: base + +- ansible.builtin.import_tasks: restore.yml + name: restore + when: restore.n8n.n8n_archive and restore.n8n.db_archive diff --git a/roles/n8n/tasks/restore.yml b/roles/n8n/tasks/restore.yml new file mode 100644 index 0000000..345da99 --- /dev/null +++ b/roles/n8n/tasks/restore.yml @@ -0,0 +1,43 @@ +--- + +- name: Copy archives + ansible.builtin.copy: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + loop: + - { src: '{{ restore.n8n.n8n_archive }}', dest: 'n8n_n8n.tar.gz' } + - { src: '{{ restore.n8n.db_archive }}', dest: 'n8n_db.tar.gz' } + +- name: Stop nextcloud container + community.docker.docker_compose: + project_src: home_assistant + state: absent + become: true + +- name: Restore backup + community.docker.docker_container: + name: volume_restore + image: volume_restore:latest + auto_remove: yes + tty: true + volumes: + - "{{ item.path }}:/backup/archive.tar.gz" + - "{{ item.volume }}:/backup/dest" + loop: + - { path: './n8n_n8n.tar.gz', volume: 'n8n_n8n' } + - { path: './n8n_db.tar.gz', volume: 'n8n_db' } + become: true + +- name: Start nextcloud container + community.docker.docker_compose: + project_src: home_assistant + state: present + become: true + +- name: Remove archive + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: + - { path: 'n8n_n8n.tar.gz' } + - { path: 'n8n_db.tar.gz' } \ No newline at end of file diff --git a/roles/protonmail/tasks/main.yml b/roles/protonmail/tasks/main.yml index 3f670ac..464309a 100644 --- a/roles/protonmail/tasks/main.yml +++ b/roles/protonmail/tasks/main.yml @@ -1,4 +1,8 @@ --- - ansible.builtin.import_tasks: base.yml - name: base \ No newline at end of file + name: base + +- ansible.builtin.import_tasks: restore.yml + name: restore + when: restore.protonmail.protonmail_archive \ No newline at end of file diff --git a/roles/protonmail/tasks/restore.yml b/roles/protonmail/tasks/restore.yml new file mode 100644 index 0000000..07c056c --- /dev/null +++ b/roles/protonmail/tasks/restore.yml @@ -0,0 +1,40 @@ +--- + +- name: Copy archives + ansible.builtin.copy: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + loop: + - { src: '{{ restore.protonmail.protonmail_archive }}', dest: 'protonmail_protonmail.tar.gz' } + +- name: Stop nextcloud container + community.docker.docker_compose: + project_src: home_assistant + state: absent + become: true + +- name: Restore backup + community.docker.docker_container: + name: volume_restore + image: volume_restore:latest + auto_remove: yes + tty: true + volumes: + - "{{ item.path }}:/backup/archive.tar.gz" + - "{{ item.volume }}:/backup/dest" + loop: + - { path: './protonmail_protonmail.tar.gz', volume: 'protonmail_protonmail' } + become: true + +- name: Start nextcloud container + community.docker.docker_compose: + project_src: home_assistant + state: present + become: true + +- name: Remove archive + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: + - { path: 'protonmail_protonmail.tar.gz' } \ No newline at end of file diff --git a/roles/traefik/tasks/main.yml b/roles/traefik/tasks/main.yml index 3f670ac..669109c 100644 --- a/roles/traefik/tasks/main.yml +++ b/roles/traefik/tasks/main.yml @@ -1,4 +1,8 @@ --- - ansible.builtin.import_tasks: base.yml - name: base \ No newline at end of file + name: base + +- ansible.builtin.import_tasks: restore.yml + name: restore + when: restore.traefik.prometheus_archive and restore.traefik.grafana_archive diff --git a/roles/traefik/tasks/restore.yml b/roles/traefik/tasks/restore.yml new file mode 100644 index 0000000..4369c66 --- /dev/null +++ b/roles/traefik/tasks/restore.yml @@ -0,0 +1,43 @@ +--- + +- name: Copy archives + ansible.builtin.copy: + src: "{{ item.src }}" + dest: "{{ item.dest }}" + loop: + - { src: '{{ restore.traefik.prometheus_archive }}', dest: 'traefik_prometheus.tar.gz' } + - { src: '{{ restore.traefik.grafana_archive }}', dest: 'traefik_grafana.tar.gz' } + +- name: Stop nextcloud container + community.docker.docker_compose: + project_src: home_assistant + state: absent + become: true + +- name: Restore backup + community.docker.docker_container: + name: volume_restore + image: volume_restore:latest + auto_remove: yes + tty: true + volumes: + - "{{ item.path }}:/backup/archive.tar.gz" + - "{{ item.volume }}:/backup/dest" + loop: + - { path: './traefik_prometheus.tar.gz', volume: 'traefik_prometheus' } + - { path: './traefik_grafana.tar.gz', volume: 'traefik_grafana' } + become: true + +- name: Start nextcloud container + community.docker.docker_compose: + project_src: home_assistant + state: present + become: true + +- name: Remove archive + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: + - { path: 'traefik_prometheus.tar.gz' } + - { path: 'traefik_grafana.tar.gz' } \ No newline at end of file