33 lines
1.6 KiB
YAML
Executable File
33 lines
1.6 KiB
YAML
Executable File
---
|
|
- name: Assert environment variable is not empty
|
|
ansible.builtin.include_tasks: "tasks/assert_env_var_not_empty.yml"
|
|
with_items: "{{ BACKUP_OVH1_REQUIRED_ENV_VARS }}"
|
|
|
|
- name: Assert variable is not empty
|
|
ansible.builtin.include_tasks: "tasks/assert_var_not_empty.yml"
|
|
with_items: "{{ BACKUP_OVH1_REQUIRED_VARS }}"
|
|
|
|
- name: Archive volumes
|
|
ansible.builtin.command: "tar -czf {{ WORKDIR }}/backup/{{ item }}.tar.gz -C /mnt/volumes {{ item }}"
|
|
with_items: "{{ BACKUP_OVH1_VOLUMES }}"
|
|
|
|
- name: Find lastest MySQL DB dump
|
|
ansible.builtin.shell: "ls -tr /mnt/volumes/mysql-server_dumps/data/mysql_dump-mysql_*"
|
|
register: MySQL_dump
|
|
|
|
- name: Find lastest applications DB dump
|
|
ansible.builtin.shell: "ls -tr /mnt/volumes/mysql-server_dumps/data/mysql_dump_*"
|
|
register: DBs_dump
|
|
|
|
- name: Archive DB dumps
|
|
ansible.builtin.command: "tar -czf {{ WORKDIR }}/backup/mysql-server_dumps.tar.gz -C /mnt/volumes {{ MySQL_dump.stdout_lines | last }} {{ DBs_dump.stdout_lines | last }}"
|
|
with_items: "{{ BACKUP_OVH1_VOLUMES }}"
|
|
|
|
- name: Backup with duplicity
|
|
ansible.builtin.command: "duplicity --num-retries 3 --full-if-older-than 1M --progress --archive-dir {{ ARCHIVE_DIR }} --name {{ lookup('env','BACKUP_WORKFLOW') }} --allow-source-mismatch '{{ WORKDIR }}/backup' swift://{{ lookup('env','BACKUP_WORKFLOW') }}"
|
|
environment: "{{ DUPLICITY_ENVIRONMENT }}"
|
|
|
|
- name: Clean old duplicity backups
|
|
ansible.builtin.command: "duplicity remove-older-than 2M --archive-dir {{ ARCHIVE_DIR }} --name {{ lookup('env','BACKUP_WORKFLOW') }} --allow-source-mismatch --force swift://{{ lookup('env','BACKUP_WORKFLOW') }}"
|
|
environment: "{{ DUPLICITY_ENVIRONMENT }}"
|