2026-03-31 21:42:50 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
HOST="${1}"
|
|
|
|
|
PORT="${2}"
|
|
|
|
|
TOKENID="${3}@${4}!${5}"
|
|
|
|
|
TOKENSECRET="${6}"
|
|
|
|
|
|
|
|
|
|
datastores=$(wget --header="Authorization: PBSAPIToken=${TOKENID}:${TOKENSECRET}" --content-on-error -q -O - "https://${HOST}:${PORT}/api2/json/admin/datastore")
|
|
|
|
|
|
|
|
|
|
IFS='
|
|
|
|
|
'
|
|
|
|
|
for datastore in $(echo "${datastores}" |jq --raw-output '.data[].store'); do
|
|
|
|
|
namespaces=$(wget --header="Authorization: PBSAPIToken=${TOKENID}:${TOKENSECRET}" --content-on-error -q -O - "https://${HOST}:${PORT}/api2/json/admin/datastore/${datastore}/namespace")
|
|
|
|
|
|
|
|
|
|
ret_namespaces=""
|
|
|
|
|
for namespace in $(echo "${namespaces}" |jq --raw-output '.data[].ns'); do
|
|
|
|
|
backups=$(wget --header="Authorization: PBSAPIToken=${TOKENID}:${TOKENSECRET}" --content-on-error -q -O - "https://${HOST}:${PORT}/api2/json/admin/datastore/${datastore}/snapshots?ns=${namespace}")
|
|
|
|
|
backups_json=$(echo "${backups}" |jq '.data')
|
2026-03-31 22:00:16 +02:00
|
|
|
ret_namespaces="${ret_namespaces}{\"${namespace}\":${backups_json}},"
|
2026-03-31 21:42:50 +02:00
|
|
|
done
|
2026-03-31 22:00:16 +02:00
|
|
|
ret_datastores="${ret_datastores}{\"${datastore}\":[${ret_namespaces::-1}]},"
|
2026-03-31 21:42:50 +02:00
|
|
|
done
|
|
|
|
|
|
2026-03-31 22:00:16 +02:00
|
|
|
ret="[${ret_datastores::-1}]"
|
2026-03-31 21:42:50 +02:00
|
|
|
|
|
|
|
|
echo $ret
|