feat(backup): 配额改按备份根占用并在超限时清理最旧批次
build / build (push) Successful in 3m22s

- 采集器上报 backup_root/usage/quota(加性字段),API 用 BACKUP_HOST_ROOT 校验并分别降级占用/配额
- 页面配额行改为备份占用 X / 配额 50 GB,4 条告警改用备份口径,解除本页归档依赖
- logical-backup.sh 预检按字节清理(保留最新、空间不足零删除),dump 后复查保护新批次
- backup_layout 写入 KB_BACKUP_QUOTA_BYTES;--show 输出根占用;新增 prune 工具与自检
This commit is contained in:
Zhero & Rin
2026-11-25 22:45:35 +08:00
committed by 姚章浩
parent 65476750b0
commit 144b49cb53
20 changed files with 1124 additions and 178 deletions
+24
View File
@@ -0,0 +1,24 @@
package backuphost
import (
"os/exec"
"strings"
"testing"
)
// 配额清理工具是唯一会删历史备份的代码。它的 self-test 覆盖「最旧优先 / 预检保留最新 /
// 空间不够零删除 / 非批次日录与符号链接不动 / dump 后保护新批次」,必须随 Go 测试一起跑。
func TestPruneBackupBatchesSelfTest(t *testing.T) {
python, err := exec.LookPath("python3")
if err != nil {
t.Skip("python3 not available")
}
command := exec.Command(python, "../../scripts/prune_backup_batches.py", "--self-test")
output, err := command.CombinedOutput()
if err != nil {
t.Fatalf("prune self-test failed: %v\n%s", err, output)
}
if !strings.Contains(string(output), "self-test ok") {
t.Fatalf("prune self-test output unexpected: %s", output)
}
}