move secrets to .env file so they work on their own, initialize restic repo on fresh deployments
31 lines
714 B
Django/Jinja
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)"
|