check-connection: verify backup namespace exists; flag namespace-not-found
This commit is contained in:
parent
0d385480d7
commit
2038e5ef88
2 changed files with 15 additions and 11 deletions
|
|
@ -87,8 +87,10 @@ read-only checks:
|
|||
|
||||
1. the files `backup.sh` needs (encryption key, exclude list) exist;
|
||||
2. `PBS_SERVER:PBS_PORT` is reachable on TCP;
|
||||
3. an authenticated API round-trip succeeds (it lists existing snapshots for
|
||||
this host on the PBS — nothing is written).
|
||||
3. an authenticated API round-trip succeeds — it confirms the token works *and*
|
||||
that the namespace `BACKUP_NS` actually exists on the server (a missing
|
||||
namespace is reported explicitly, so a new host fails here until its
|
||||
namespace has been created: `proxmox-backup-client namespace create <ns>`).
|
||||
|
||||
It prints a `[ok]` per check and exits 0 on success, 1 on failure:
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue