Skip to content
Snippets Groups Projects
backup-standalone.j2 963 B
Newer Older
nd's avatar
nd committed
#!/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 %}
nd's avatar
nd committed

{% if backup_backend == 'restic' %}
# Run restic in subshell to avoid leaking environment to post_run hooks
(
	# restic backend
	source /etc/backup-client/restic.env
nd's avatar
nd committed

Julian's avatar
Julian committed
	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"
)
nd's avatar
nd committed
{% 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 %}