fix: max_by had wrong exp and just returned last from array

This commit is contained in:
2026-04-02 18:53:00 +02:00
parent bbd1c6f6c0
commit 287efe373d
+1 -1
View File
@@ -14,7 +14,7 @@ for datastore in $(echo "${datastores}" |jq --raw-output '.data[].store'); do
for namespace in $(echo "${namespaces}" |jq --raw-output '.data[].ns'); do for namespace in $(echo "${namespaces}" |jq --raw-output '.data[].ns'); do
# group backups by backup-type and backup-id, only get the backup of each group (thus the map) with max backup-time and add datastore and namespace to each backup # group backups by backup-type and backup-id, only get the backup of each group (thus the map) with max backup-time and add datastore and namespace to each backup
temp=$(wget --header="Authorization: PBSAPIToken=${TOKENID}:${TOKENSECRET}" --content-on-error -q -O - "https://${HOST}:${PORT}/api2/json/admin/datastore/${datastore}/snapshots?ns=${namespace}" |jq ".data |group_by([.\"backup-type\", .\"backup-id\"]) |map(max_by(\".backup-time\")) |map(.datastore |= \"${datastore}\") |map(.namespace |= \"${namespace}\")") temp=$(wget --header="Authorization: PBSAPIToken=${TOKENID}:${TOKENSECRET}" --content-on-error -q -O - "https://${HOST}:${PORT}/api2/json/admin/datastore/${datastore}/snapshots?ns=${namespace}" |jq ".data |group_by([.\"backup-type\", .\"backup-id\"]) |map(max_by(.\"backup-time\")) |map(.datastore |= \"${datastore}\") |map(.namespace |= \"${namespace}\")")
# remove array symbols ([ and ]) # remove array symbols ([ and ])
temp="${temp:1}" temp="${temp:1}"