post_run and pre_run hook support
This commit is contained in:
parent
231c983205
commit
e7d5a2cbc7
3 changed files with 40 additions and 12 deletions
|
|
@ -3,21 +3,38 @@ 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' %}
|
||||
# restic backend
|
||||
source /etc/backup-client/restic.env
|
||||
|
||||
restic backup \
|
||||
{{ restic_combined_flags }} \
|
||||
--verbose \
|
||||
--exclude-caches \
|
||||
--one-file-system \
|
||||
--exclude "${RESTIC_REPOSITORY}" \
|
||||
--exclude-file "/etc/backup-client/exclude_files" \
|
||||
--files-from "/etc/backup-client/include_files"
|
||||
|
||||
# Run restic in subshell to avoid leaking environment to post_run hooks
|
||||
(
|
||||
# restic backend
|
||||
source /etc/backup-client/restic.env
|
||||
|
||||
restic backup \
|
||||
{{ restic_combined_flags }} \
|
||||
--verbose \
|
||||
--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 %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue