Ajout de fonctions backup et restore des données des conteneurs docker
This commit is contained in:
parent
94dffdcf33
commit
d6fb655fce
2 changed files with 44 additions and 0 deletions
23
tasks/backup.yml
Normal file
23
tasks/backup.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
- name: docker directory
|
||||
file:
|
||||
path: "{{ docker_wordpress_backup_dir }}"
|
||||
state: directory
|
||||
|
||||
- name: stop before backup
|
||||
shell: |
|
||||
docker-compose down
|
||||
args:
|
||||
chdir: /opt/{{ docker_wordpress_service_id }}/
|
||||
|
||||
- name: backup
|
||||
shell: |
|
||||
rsync -a --delete "{{ docker_wordpress_data_dir }}/{{ docker_wordpress_service_id }}/{{ item }}" "{{ docker_wordpress_backup_dir }}/{{ docker_wordpress_service_id }}/"
|
||||
with_items:
|
||||
- mysql
|
||||
- wp_html
|
||||
|
||||
- name: start after backup
|
||||
shell: |
|
||||
docker-compose up -d
|
||||
args:
|
||||
chdir: /opt/{{ docker_wordpress_service_id }}/
|
21
tasks/restore.yml
Normal file
21
tasks/restore.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
- name: stop before restore
|
||||
shell: |
|
||||
docker-compose down
|
||||
args:
|
||||
chdir: /opt/{{ docker_wordpress_service_id }}/
|
||||
|
||||
- name: restore
|
||||
shell: |
|
||||
rsync -a --delete "{{ docker_wordpress_backup_dir }}/{{ docker_wordpress_service_id }}/{{ item }}" "{{ docker_wordpress_data_dir }}/{{ docker_wordpress_service_id }}/"
|
||||
with_items:
|
||||
- mysql
|
||||
- wp_html
|
||||
|
||||
- name: start after restore
|
||||
shell: |
|
||||
docker-compose up -d
|
||||
args:
|
||||
chdir: /opt/{{ docker_wordpress_service_id }}/
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue