Files
buryan-infra/ops/scripts/pve_cleanup_stale_locks.sh
T
2026-11-18 11:12:37 +03:00

18 lines
617 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.
#!/bin/bash
# Снять stale backup-lock с CT, если реального vzdump нет. Запускается до pve-guests.
set -u
LOG=/var/log/pve-stale-locks.log
for f in /etc/pve/lxc/*.conf; do
[ -f "$f" ] || continue
id=$(basename "$f" .conf)
lock=$(grep -E '^lock:' "$f" | awk '{print $2}' | head -1)
[ "$lock" = "backup" ] || continue
if pgrep -f "vzdump.*$id" >/dev/null 2>&1; then
echo "$(date '+%F %T') CT$id backup lock active, skip" >> "$LOG"
continue
fi
if pct unlock "$id" >>"$LOG" 2>&1; then
echo "$(date '+%F %T') CT$id stale backup lock removed" >> "$LOG"
fi
done