diff --git a/inventory/host_vars/frederica.dmz.mateu.be.yml b/inventory/host_vars/frederica.dmz.mateu.be.yml index d68bbcf..734ebe0 100644 --- a/inventory/host_vars/frederica.dmz.mateu.be.yml +++ b/inventory/host_vars/frederica.dmz.mateu.be.yml @@ -1,14 +1,17 @@ --- +restic_path: "/mnt/tank/restic/restic" +restic_script_path: "/mnt/tank/restic/resticbackup.sh" +restic_cache_dir: "/mnt/tank/restic/cache" + restic_backup_path: - /mnt/tank restic_backup_excluded_path: + - /mnt/tank/ix-applications - /mnt/tank/s3/.minio.sys - - /mnt/tank/iocage + - /mnt/tank/restic/cache restic_backup_hour: 6 restic_backup_minute: 45 -ansible_python_interpreter: /usr/local/bin/python3 - restic_aws_access_key_id: "SCW0VAFXE5MN9N8KVHTQ" restic_aws_secret_access_key: !vault | $ANSIBLE_VAULT;1.1;AES256 diff --git a/roles/restic/defaults/main.yml b/roles/restic/defaults/main.yml index da750d1..2fe5b40 100644 --- a/roles/restic/defaults/main.yml +++ b/roles/restic/defaults/main.yml @@ -1,4 +1,7 @@ --- +restic_path: "/usr/local/bin/restic" +restic_script_path: "/usr/local/bin/resticbackup.sh" +restic_cache_dir: "" restic_pass: !vault | $ANSIBLE_VAULT;1.1;AES256 diff --git a/roles/restic/tasks/install.yml b/roles/restic/tasks/install.yml index 701384a..0fd37f1 100644 --- a/roles/restic/tasks/install.yml +++ b/roles/restic/tasks/install.yml @@ -17,3 +17,12 @@ mode: "0o755" owner: root group: "{{ restic_exe_group }}" + +- name: Create cache dir + ansible.builtin.file: + name: "{{ restic_cache_dir }}" + state: directory + owner: root + group: "{{ restic_exe_group }}" + mode: "0o700" + when: restic_cache_dir | length > 0 diff --git a/roles/restic/templates/resticbackup.sh.j2 b/roles/restic/templates/resticbackup.sh.j2 index e7f6150..f7eeecd 100644 --- a/roles/restic/templates/resticbackup.sh.j2 +++ b/roles/restic/templates/resticbackup.sh.j2 @@ -7,7 +7,7 @@ export AWS_ACCESS_KEY_ID="{{ restic_aws_access_key_id }}" export AWS_SECRET_ACCESS_KEY="{{ restic_aws_secret_access_key }}" ## lancement de la sauvegarde -{{ restic_path }} backup --exclude-caches {% for i in restic_backup_excluded_path %} -e {{ i }} {% endfor %} {% for i in restic_backup_path %}{{ i }} {% endfor %} +{{ restic_path }} backup {% if restic_cache_dir | length > 0 %}--cache-dir {{ restic_cache_dir }}{% endif %} --exclude-caches {% for i in restic_backup_excluded_path %} -e {{ i }} {% endfor %} {% for i in restic_backup_path %}{{ i }} {% endfor %} ## récupération de l'espace {{ restic_path }} forget --prune -d 7 -w 4 -m 3 -y 1 diff --git a/roles/restic/vars/main.yml b/roles/restic/vars/main.yml index dcbe6d4..6afdd17 100644 --- a/roles/restic/vars/main.yml +++ b/roles/restic/vars/main.yml @@ -1,11 +1,7 @@ --- - restic_version: "0.17.1" restic_architecture: "amd64" restic_system: "{{ ansible_facts['system'] | lower }}" restic_download_url: "https://github.com/restic/restic/releases/download/v{{ restic_version }}/restic_{{ restic_version }}_{{ restic_system }}_{{ restic_architecture }}.bz2" -restic_path: "/usr/local/bin/restic" -restic_script_path: "/usr/local/bin/resticbackup.sh" - restic_repository: "s3:{{ restic_s3_url }}/{{ inventory_hostname }}"