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 #!/usr/bin/env bash
set -o pipefail
function usage() { function usage() {
local full=${1:-false} local full=${1:-false}
cat <<EOF cat <<EOF
@@ -181,24 +183,27 @@ function may_select() {
} }
function select_group() { function select_group() {
local groups local groups raw
readarray -t groups < <(get_group_names) raw=$(get_group_names) || { echo "Error: failed to query PBS!" >&2; return 1; }
(( ${#groups[@]} == 0 )) && return 2 [ -z "$raw" ] && return 2
readarray -t groups <<< "$raw"
PS3="Snapshot group [1-${#groups[@]}]: " PS3="Snapshot group [1-${#groups[@]}]: "
GROUP=$(may_select "$1" "${groups[@]}") || { echo "Error: invalid group" >&2; return 1; } GROUP=$(may_select "$1" "${groups[@]}") || { echo "Error: invalid group" >&2; return 1; }
} }
function select_snapshot_and_archive() { function select_snapshot_and_archive() {
local snapshots archives local snapshots archives raw
readarray -t snapshots < <(get_snapshot_names) raw=$(get_snapshot_names) || { echo "Error: failed to query PBS!" >&2; return 1; }
(( ${#snapshots[@]} == 0 )) && return 2 [ -z "$raw" ] && return 2
readarray -t snapshots <<< "$raw"
PS3="Snapshot [1-${#snapshots[@]}]: " PS3="Snapshot [1-${#snapshots[@]}]: "
SNAPSHOT=$(may_select "$1" "${snapshots[@]}") || { echo "Error: invalid snapshot" >&2; return 1; } SNAPSHOT=$(may_select "$1" "${snapshots[@]}") || { echo "Error: invalid snapshot" >&2; return 1; }
readarray -t archives < <(get_snapshot_files "$SNAPSHOT") raw=$(get_snapshot_files "$SNAPSHOT") || { echo "Error: failed to query PBS!" >&2; return 1; }
(( ${#archives[@]} == 0 )) && return 3 [ -z "$raw" ] && return 3
readarray -t archives <<< "$raw"
PS3="Archive [1-${#archives[@]}]: " PS3="Archive [1-${#archives[@]}]: "
ARCHIVE=$(may_select "$2" "${archives[@]}") || { echo "Error: invalid archive" >&2; return 1; } ARCHIVE=$(may_select "$2" "${archives[@]}") || { echo "Error: invalid archive" >&2; return 1; }