[BACKUP_RESTORE] Add docker + begin implement for nextcloud service
This commit is contained in:
parent
1419a89d03
commit
efa7c2e42d
8 changed files with 81 additions and 2 deletions
|
@ -14,4 +14,8 @@ acme:
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
protonmail:
|
protonmail:
|
||||||
initialized: false
|
initialized: false
|
||||||
|
|
||||||
|
restore:
|
||||||
|
cloud:
|
||||||
|
nextcloud_archive: /home/florian/Documents/Projet/Perso/backup/cloud/nextcloud.latest.tar.gz
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- { role: docker, tags: ["docker"] }
|
- { role: docker, tags: ["docker"] }
|
||||||
|
- { role: volume_restore, tags: ["volume_restore"] }
|
||||||
- { role: ssh, tags: ["ssh"] }
|
- { role: ssh, tags: ["ssh"] }
|
||||||
- { role: traefik, tags: ["traefik"] }
|
- { role: traefik, tags: ["traefik"] }
|
||||||
- { role: whoami, tags: ["whoami"] }
|
- { role: whoami, tags: ["whoami"] }
|
||||||
|
|
|
@ -4,4 +4,8 @@
|
||||||
name: base
|
name: base
|
||||||
|
|
||||||
- ansible.builtin.import_tasks: cron.yml
|
- ansible.builtin.import_tasks: cron.yml
|
||||||
name: cron
|
name: cron
|
||||||
|
|
||||||
|
- ansible.builtin.import_tasks: restore_nextcloud.yml
|
||||||
|
name: restore_nextcloud
|
||||||
|
when: restore.cloud.nextcloud_archive
|
36
roles/cloud/tasks/restore_nextcloud.yml
Normal file
36
roles/cloud/tasks/restore_nextcloud.yml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- 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
|
7
roles/volume_restore/files/Dockerfile
Normal file
7
roles/volume_restore/files/Dockerfile
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk add --update --no-cache tar
|
||||||
|
|
||||||
|
RUN mkdir -p /backup/dest
|
||||||
|
|
||||||
|
CMD ["tar", "-xf", "/backup/archive.tar.gz", "--strip-components=1", "-C", "/backup/dest"]
|
5
roles/volume_restore/files/README.md
Normal file
5
roles/volume_restore/files/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# HOW TO USE IT
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -v [PATH_TO_ARCHIVE]:/backup/archive.tar.gz -v [DIST_VOLUME]:/backup/dest volume_restore:latest
|
||||||
|
```
|
18
roles/volume_restore/tasks/base.yml
Normal file
18
roles/volume_restore/tasks/base.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Copy conf
|
||||||
|
ansible.builtin.copy:
|
||||||
|
backup: true
|
||||||
|
src: .
|
||||||
|
dest: volume_restore/
|
||||||
|
register: volume_restore_copy
|
||||||
|
|
||||||
|
- name: Build image
|
||||||
|
community.docker.docker_image:
|
||||||
|
name: volume_restore
|
||||||
|
tag: latest
|
||||||
|
build:
|
||||||
|
path: volume_restore
|
||||||
|
source: build
|
||||||
|
become: yes
|
||||||
|
when: volume_restore_copy.changed
|
4
roles/volume_restore/tasks/main.yml
Normal file
4
roles/volume_restore/tasks/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- ansible.builtin.import_tasks: base.yml
|
||||||
|
name: base
|
Loading…
Reference in a new issue