report PBC query failures instead of an empty datastore

This commit is contained in:
2026-08-22 07:39:16 +02:00
parent 73202f5e3b
commit 56b619372d
+13 -8
View File
@@ -1,5 +1,7 @@
#!/usr/bin/env bash
set -o pipefail
function usage() {
local full=${1:-false}
cat <<EOF
@@ -181,24 +183,27 @@ function may_select() {
}
function select_group() {
local groups
readarray -t groups < <(get_group_names)
(( ${#groups[@]} == 0 )) && return 2
local groups raw
raw=$(get_group_names) || { echo "Error: failed to query PBS!" >&2; return 1; }
[ -z "$raw" ] && return 2
readarray -t groups <<< "$raw"
PS3="Snapshot group [1-${#groups[@]}]: "
GROUP=$(may_select "$1" "${groups[@]}") || { echo "Error: invalid group" >&2; return 1; }
}
function select_snapshot_and_archive() {
local snapshots archives
readarray -t snapshots < <(get_snapshot_names)
(( ${#snapshots[@]} == 0 )) && return 2
local snapshots archives raw
raw=$(get_snapshot_names) || { echo "Error: failed to query PBS!" >&2; return 1; }
[ -z "$raw" ] && return 2
readarray -t snapshots <<< "$raw"
PS3="Snapshot [1-${#snapshots[@]}]: "
SNAPSHOT=$(may_select "$1" "${snapshots[@]}") || { echo "Error: invalid snapshot" >&2; return 1; }
readarray -t archives < <(get_snapshot_files "$SNAPSHOT")
(( ${#archives[@]} == 0 )) && return 3
raw=$(get_snapshot_files "$SNAPSHOT") || { echo "Error: failed to query PBS!" >&2; return 1; }
[ -z "$raw" ] && return 3
readarray -t archives <<< "$raw"
PS3="Archive [1-${#archives[@]}]: "
ARCHIVE=$(may_select "$2" "${archives[@]}") || { echo "Error: invalid archive" >&2; return 1; }