check-connection: verify backup namespace exists; flag namespace-not-found

This commit is contained in:
Christoph Haas 2026-09-20 11:53:04 +00:00
parent 0d385480d7
commit 2038e5ef88
2 changed files with 15 additions and 11 deletions

View file

@ -8,7 +8,6 @@ source "$SCRIPT_DIR/backup.env"
# ==============================================================================
# CONNECTION CHECK
# ==============================================================================
BACKUP_LABEL="${HOSTNAME}-root"
EXCLUDE_FILE="/opt/backup/exclude"
fail() {
@ -33,17 +32,20 @@ fi
echo "[ok] TCP connection to ${PBS_SERVER}:${PBS_PORT}"
echo
# 3. Authenticated round-trip: list existing snapshots for this host
if ! SNAP_OUT="$(timeout 30 proxmox-backup-client snapshot list "host/${BACKUP_LABEL}" --ns "$BACKUP_NS" 2>&1)"; then
echo "$SNAP_OUT" >&2
# 3. Authenticated round-trip + namespace existence: list backups in our namespace
if ! LIST_OUT="$(timeout 30 proxmox-backup-client list --ns "$BACKUP_NS" 2>&1)"; then
if echo "$LIST_OUT" | grep -q "ENOENT"; then
fail "namespace '${BACKUP_NS}' does not exist on ${PBS_SERVER} — create it, or point BACKUP_NS at an existing namespace"
fi
echo "$LIST_OUT" >&2
fail "authenticated request failed — check PBS_AUTH_ID / PBS_PASSWORD in backup.env"
fi
echo "[ok] authentication + API round-trip to the server"
if [ -n "$SNAP_OUT" ]; then
echo "existing snapshots for ${BACKUP_LABEL}:"
echo "$SNAP_OUT"
echo "[ok] authentication + API round-trip to the server (namespace ${BACKUP_NS} exists)"
if [ -n "$LIST_OUT" ]; then
echo "existing backups in namespace ${BACKUP_NS}:"
echo "$LIST_OUT"
else
echo " (none yet for ${BACKUP_LABEL} — the first backup has not run)"
echo " (no backups there yet — the first one has not run)"
fi
echo