Files
ansible/roles/backup/templates/restic-backup.sh.j2
T
alessandrovitali 71a02e0f86 refactor: harden restic configuration
move secrets to .env file so they work on their own, initialize restic repo on fresh deployments
2026-07-12 23:46:29 +02:00

31 lines
714 B
Django/Jinja

#!/bin/bash
## Ansible managed
set -e
# Source environment variables if running manually/outside Systemd
if [ -f /etc/restic-backup.env ]; then
# shellcheck source=/dev/null
. /etc/restic-backup.env
fi
echo "Starting Restic Backup at $(date)"
## Run the backup using paths and exclusions defined as group_vars
restic backup \
{% for path in backup_include_paths %}
"{{ path }}" \
{% endfor %}
{% for path in backup_exclude_paths %}
--exclude "{{ path }}" \
{% endfor %}
--cleanup-cache
restic forget \
--prune \
--keep-daily {{ backup_retention_daily }} \
--keep-weekly {{ backup_retention_weekly }} \
--keep-monthly {{ backup_retention_monthly }}
echo "Restic backup completed at $(date)"