setup cron local mail reporting and longhorn recurring backup job

This commit is contained in:
2025-09-01 19:38:50 +02:00
parent 2d4cb5d8a5
commit 6d3adb5834
11 changed files with 278 additions and 25 deletions

View File

@@ -25,6 +25,16 @@
- name: test backup_cmd
ansible.builtin.shell: |
{{ backup_cmd }} > /dev/null
- name: Créer le script de backup
copy:
dest: "{{ scripts_dir }}/backup.sh"
mode: '0755'
content: |
#!/bin/bash
set -e
{{ backup_cmd }} | gzip > {{ backup_dir }}/backup_$(date +\%Y\%m\%d).sql.gz
find {{ backup_dir }} -type f -name 'backup_*.sql.gz' -mtime +{{ keep_days }} -delete
- name: Ajouter une tâche cron pour dump PostgreSQL tous les jours à 4h avec compression
cron:
@@ -32,9 +42,7 @@
minute: "0"
hour: "4"
user: root
job: >-
{{ backup_cmd }} | gzip > {{ backup_dir }}/backup_$(date +\\%Y\\%m\\%d).sql.gz
&& find {{ backup_dir }} -type f -name 'backup_*.sql.gz' -mtime +{{ keep_days }} -delete
job: "{{ scripts_dir }}/backup.sh"
- name: Créer le script de restauration
copy: