Files
miyagi-backup-v3/hooks.d/post-backup/20-pve-log-clear.sh
T

19 lines
876 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Post-Backup-Hook: alte vzdump-Logs auf SOURCEHOST löschen (>30 Tage)
#
# Ablage: /etc/miyagi-backup/hooks.d/post-backup/
# Ausführung: chmod +x <hookname>.sh
# Reihenfolge: alphabetisch (01-foo.sh, 02-bar.sh, ...)
# Fehlerverhalten: Exit != 0 erzeugt WARNUNG im Log, weitere Hooks laufen weiter
#
# Migriert aus run_pve_log_clear() (v3/miyagi-backup.sh). Braucht SOURCEHOST/
# SOURCEPORT/SOURCEUSER aus der miyagi-Config (werden vom Hauptskript exportiert).
set -uo pipefail
[[ -z "${SOURCEHOST:-}" ]] && { echo "SOURCEHOST nicht gesetzt – übersprungen."; exit 0; }
echo "Räume alte vzdump-Logs auf ($SOURCEHOST)..."
ssh -o BatchMode=yes -o ConnectTimeout=10 -p "${SOURCEPORT:-22}" "${SOURCEUSER:-root}@${SOURCEHOST}" \
find /var/log/vzdump -type f -mtime +30 -delete \
|| echo "Fehler beim Aufräumen der vzdump-Logs auf $SOURCEHOST"