fix: PBS Backup-Anzahl via find statt snapshot-Befehl (existiert nicht in dieser PBS-Version)
This commit is contained in:
parent
e565039743
commit
5995f2e9cc
@ -5,6 +5,8 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PBSInfo struct {
|
type PBSInfo struct {
|
||||||
@ -88,11 +90,16 @@ func CollectPBS() *PBSInfo {
|
|||||||
if avail, ok := d["avail"].(float64); ok {
|
if avail, ok := d["avail"].(float64); ok {
|
||||||
ds.Available = int64(avail)
|
ds.Available = int64(avail)
|
||||||
}
|
}
|
||||||
// Backup-Anzahl ermitteln
|
// Backup-Anzahl: Zeitstempel-Verzeichnisse zaehlen (depth 3 ohne ns, depth 5 mit ns)
|
||||||
if snapOut, err := exec.Command("/usr/sbin/proxmox-backup-manager", "snapshot", "list", ds.Name, "--output-format", "json").Output(); err == nil {
|
// Struktur: <path>/<type>/<id>/<timestamp> oder <path>/ns/<ns>/<type>/<id>/<timestamp>
|
||||||
var snaps []interface{}
|
if ds.Path != "" {
|
||||||
if json.Unmarshal(snapOut, &snaps) == nil {
|
// Alle Timestamp-Verzeichnisse: entweder depth 3 (ohne ns) oder depth 5 (mit ns)
|
||||||
ds.BackupCount = len(snaps)
|
countCmd := exec.Command("/bin/sh", "-c",
|
||||||
|
"find "+ds.Path+" \\( -mindepth 3 -maxdepth 3 -o -mindepth 5 -maxdepth 5 \\) -type d 2>/dev/null | grep -cE '^.*[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$'")
|
||||||
|
if out, err := countCmd.Output(); err == nil {
|
||||||
|
if n, err := strconv.Atoi(strings.TrimSpace(string(out))); err == nil {
|
||||||
|
ds.BackupCount = n
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user