initial pfannkuchen
This commit is contained in:
parent
b6dafc7a73
commit
4d305fa19f
99 changed files with 3575 additions and 321 deletions
33
roles/borg/templates/borg-backup.sh.j2
Normal file
33
roles/borg/templates/borg-backup.sh.j2
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
export BORG_PASSPHRASE=$(cat /root/.borg-passphrase)
|
||||
REPO="{{ borg_repo }}"
|
||||
LOGFILE="{{ borg_logfile }}"
|
||||
|
||||
echo "[$(date)] Starte Backup: {{ inventory_hostname }}" >> "$LOGFILE"
|
||||
|
||||
borg create \
|
||||
--verbose \
|
||||
--filter AME \
|
||||
--remote-path={{ borg_remote_path }} \
|
||||
--stats \
|
||||
--show-rc \
|
||||
--compression {{ borg_compression }} \
|
||||
"${REPO}::{{ inventory_hostname }}-$(date +%Y-%m-%d_%H-%M)" \
|
||||
{{ backup_source }} >> "$LOGFILE" 2>&1
|
||||
|
||||
BACKUP_RC=$?
|
||||
|
||||
borg prune -v --list "${REPO}" \
|
||||
--keep-daily={{ borg_retention_daily }} \
|
||||
--keep-weekly={{ borg_retention_weekly }} \
|
||||
--keep-monthly={{ borg_retention_monthly }} >> "$LOGFILE" 2>&1
|
||||
|
||||
PRUNE_RC=$?
|
||||
|
||||
borg compact "${REPO}" >> "$LOGFILE" 2>&1
|
||||
|
||||
GLOBAL_RC=$(( BACKUP_RC > PRUNE_RC ? BACKUP_RC : PRUNE_RC ))
|
||||
echo "[$(date)] Backup beendet mit Code $GLOBAL_RC" >> "$LOGFILE"
|
||||
exit $GLOBAL_RC
|
||||
Loading…
Add table
Add a link
Reference in a new issue