40 lines
963 B
Django/Jinja
Executable file
40 lines
963 B
Django/Jinja
Executable file
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
test -f "/etc/backup-client/enabled" || { echo "Standalone backup is disabled"; exit 0; }
|
|
|
|
{% if backups.hooks.pre_run %}
|
|
echo "Running pre_run hooks"
|
|
{% for cmd in backups.hooks.pre_run %}
|
|
( {{ cmd }} )
|
|
{% endfor %}
|
|
echo "Hooks done"
|
|
{% endif %}
|
|
|
|
{% if backup_backend == 'restic' %}
|
|
# Run restic in subshell to avoid leaking environment to post_run hooks
|
|
(
|
|
# restic backend
|
|
source /etc/backup-client/restic.env
|
|
|
|
export RESTIC_PROGRESS_FPS=1
|
|
restic backup \
|
|
{{ restic_combined_flags }} \
|
|
--exclude-caches \
|
|
--one-file-system \
|
|
--exclude "${RESTIC_REPOSITORY}" \
|
|
--exclude-file "/etc/backup-client/exclude_files" \
|
|
--files-from "/etc/backup-client/include_files"
|
|
)
|
|
{% endif %}
|
|
{% if not backup_backend %}
|
|
echo "Noop, backup is handled external"
|
|
{% endif %}
|
|
|
|
{% if backups.hooks.post_run %}
|
|
echo "Running post_run hooks"
|
|
{% for cmd in backups.hooks.post_run %}
|
|
( {{ cmd }} )
|
|
{% endfor %}
|
|
echo "Hooks done"
|
|
{% endif %}
|