Files
miyagi-backup-v3/hooks.d/post-backup/10-pbs-log-clear.sh
T

19 lines
847 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 PBS-Task-Logs löschen (>60 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_pbs_log_clear() (v3/miyagi-backup.sh). Braucht PBSHOST/
# PBSPORT/PBSUSER aus der miyagi-Config (werden vom Hauptskript exportiert).
set -uo pipefail
[[ -z "${PBSHOST:-}" ]] && { echo "PBSHOST nicht gesetzt – übersprungen."; exit 0; }
echo "Räume alte PBS-Task-Logs auf ($PBSHOST)..."
ssh -o BatchMode=yes -o ConnectTimeout=10 -p "${PBSPORT:-22}" "${PBSUSER:-root}@${PBSHOST}" \
find /var/log/proxmox-backup/tasks/ -type f -mtime +60 -delete \
|| echo "Fehler beim Aufräumen der PBS-Logs auf $PBSHOST"