[CLOUD] First work of restore backup

This commit is contained in:
Florian RICHER 2023-05-21 18:31:35 +02:00
parent efa7c2e42d
commit 7dd38fd226
6 changed files with 55 additions and 41 deletions

View file

@ -6,6 +6,6 @@
- ansible.builtin.import_tasks: cron.yml
name: cron
- ansible.builtin.import_tasks: restore_nextcloud.yml
name: restore_nextcloud
when: restore.cloud.nextcloud_archive
- ansible.builtin.import_tasks: restore.yml
name: restore
when: restore.cloud.nextcloud_archive and restore.cloud.db_archive

View file

@ -0,0 +1,42 @@
---
- name: Copy archives
ansible.builtin.copy:
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' }
- name: Stop nextcloud container
community.docker.docker_compose:
project_src: cloud
state: absent
become: true
- name: Restore backup
community.docker.docker_container:
name: volume_restore
image: volume_restore:latest
auto_remove: yes
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' }
become: true
- name: Start nextcloud container
community.docker.docker_compose:
project_src: cloud
state: present
become: true
- name: Remove archive
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop:
- { path: 'nextcloud_archive.tar.gz' }
- { path: 'db_archive.tar.gz' }

View file

@ -1,36 +0,0 @@
---
- name: Copy archive
ansible.builtin.copy:
src: "{{ restore.cloud.nextcloud_archive }}"
dest: archive.tar.gz
- name: Stop nextcloud container
community.docker.docker_compose:
project_src: cloud
state: absent
services: nextcloud
become: true
- name: Restore backup
community.docker.docker_container:
name: volume_restore
image: volume_restore:latest
state: present
recreate: true
volumes:
- ./archive.tar.gz:/backup/archive.tar.gz
- cloud_nextcloud:/backup/dest
become: true
- name: Start nextcloud container
community.docker.docker_compose:
project_src: cloud
state: present
services: nextcloud
become: true
- name: Remove archive
ansible.builtin.file:
path: archive.tar.gz
state: absent