diff --git a/README.backup.md b/README.backup.md index 537faba..7da32c2 100644 --- a/README.backup.md +++ b/README.backup.md @@ -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 `). It prints a `[ok]` per check and exits 0 on success, 1 on failure: diff --git a/check-connection.sh b/check-connection.sh index e2d35b5..80d0c34 100755 --- a/check-connection.sh +++ b/check-connection.sh @@ -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