A free, open, self-hosted app platform (GNU AGPLv3): one-click app deploys, Traefik reverse proxy with automatic SSL, rootless Docker support, gluetun VPN routing, and a web dashboard to manage it all. Free & open forever to self-host; optional paid hosted services fund it. See PROMISE.md. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: librelad <librelad@digitalangels.vip>
51 lines
1.4 KiB
Bash
51 lines
1.4 KiB
Bash
#!/bin/bash
|
|
|
|
borgCheckLocation()
|
|
{
|
|
local idx="$1"
|
|
local read_data="$2"
|
|
|
|
borgEnvExport "$idx" || return 1
|
|
|
|
local args=(check)
|
|
if [[ "$read_data" == "full" ]]; then
|
|
args+=(--verify-data)
|
|
fi
|
|
|
|
isNotice "Checking $(resticLocationName "$idx")${read_data:+ (full data verify)}"
|
|
sudo -E -u "$docker_install_user" borg "${args[@]}"
|
|
local rc=$?
|
|
borgEnvUnset
|
|
if [[ $rc -eq 0 ]]; then
|
|
isSuccessful "$(resticLocationName "$idx") integrity OK"
|
|
else
|
|
isError "$(resticLocationName "$idx") integrity FAILED"
|
|
fi
|
|
return $rc
|
|
}
|
|
|
|
borgLocationStats()
|
|
{
|
|
local idx="$1"
|
|
borgEnvExport "$idx" || return 1
|
|
local raw
|
|
raw=$(sudo -E -u "$docker_install_user" borg info --json 2>/dev/null)
|
|
borgEnvUnset
|
|
[[ -z "$raw" ]] && { echo '{"total_size":0,"total_file_count":0}'; return 0; }
|
|
|
|
if command -v jq >/dev/null 2>&1; then
|
|
echo "$raw" | jq -c '{
|
|
total_size: (.cache.stats.unique_csize // 0),
|
|
total_file_count: (.archives | length)
|
|
}'
|
|
else
|
|
echo "$raw" | python3 -c '
|
|
import json, sys
|
|
raw = json.load(sys.stdin)
|
|
size = raw.get("cache", {}).get("stats", {}).get("unique_csize", 0)
|
|
count = len(raw.get("archives", []))
|
|
print(json.dumps({"total_size": size, "total_file_count": count}))
|
|
' 2>/dev/null || echo '{"total_size":0,"total_file_count":0}'
|
|
fi
|
|
}
|