---
# Configure automated backup cron job

- name: Ensure backup script is executable
  ansible.builtin.file:
    path: "{{ cml_deploy_path }}/scripts/backup.sh"
    mode: "0755"

- name: Configure daily backup cron
  ansible.builtin.cron:
    name: "changemaker-lite-backup"
    minute: "{{ cml_backup_cron_minute }}"
    hour: "{{ cml_backup_cron_hour }}"
    job: "cd {{ cml_deploy_path }} && ./scripts/backup.sh{% if cml_backup_s3_enabled %} --s3{% endif %} --retention {{ cml_backup_retention_days }} >> {{ cml_deploy_path }}/logs/backup.log 2>&1"
    user: "{{ ansible_user }}"
