Merge branch 'master' of git.cccv.de:infra/ansible/roles/backup-client
This commit is contained in:
commit
740ca41cf9
3 changed files with 40 additions and 12 deletions
|
|
@ -100,4 +100,12 @@ exclude_files: {}
|
||||||
# Only supportet in restic based backups
|
# Only supportet in restic based backups
|
||||||
# Ignored in vm-via-hypervisor mode
|
# Ignored in vm-via-hypervisor mode
|
||||||
include_files: {}
|
include_files: {}
|
||||||
|
|
||||||
|
# Run one or more hooks before and after each (standalone) backup run
|
||||||
|
# Items are executed in bash in their own subshell
|
||||||
|
hooks:
|
||||||
|
pre_run:
|
||||||
|
- mysqldump --all-databases > /var/backups/mysql-backup.sql
|
||||||
|
post_run:
|
||||||
|
- rm /var/backups/mysql-backup.sql
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -49,3 +49,6 @@ backups:
|
||||||
'/var/log/**/*.gz': true
|
'/var/log/**/*.gz': true
|
||||||
include_files:
|
include_files:
|
||||||
'/': true
|
'/': true
|
||||||
|
hooks:
|
||||||
|
pre_run: []
|
||||||
|
post_run: []
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,21 @@ set -euo pipefail
|
||||||
|
|
||||||
test -f "/etc/backup-client/enabled" || { echo "Standalone backup is disabled"; exit 0; }
|
test -f "/etc/backup-client/enabled" || { echo "Standalone backup is disabled"; exit 0; }
|
||||||
|
|
||||||
{% if backup_backend == 'restic' %}
|
{% if backups.hooks.pre_run %}
|
||||||
# restic backend
|
echo "Running pre_run hooks"
|
||||||
source /etc/backup-client/restic.env
|
{% for cmd in backups.hooks.pre_run %}
|
||||||
|
( {{ cmd }} )
|
||||||
|
{% endfor %}
|
||||||
|
echo "Hooks done"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
restic backup \
|
{% if backup_backend == 'restic' %}
|
||||||
|
# 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 }} \
|
{{ restic_combined_flags }} \
|
||||||
--verbose \
|
--verbose \
|
||||||
--exclude-caches \
|
--exclude-caches \
|
||||||
|
|
@ -15,9 +25,16 @@ restic backup \
|
||||||
--exclude "${RESTIC_REPOSITORY}" \
|
--exclude "${RESTIC_REPOSITORY}" \
|
||||||
--exclude-file "/etc/backup-client/exclude_files" \
|
--exclude-file "/etc/backup-client/exclude_files" \
|
||||||
--files-from "/etc/backup-client/include_files"
|
--files-from "/etc/backup-client/include_files"
|
||||||
|
)
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not backup_backend %}
|
{% if not backup_backend %}
|
||||||
echo "Noop, backup is handled external"
|
echo "Noop, backup is handled external"
|
||||||
{% endif %}
|
{% 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