refactor: 移除备份恢复功能(API/CLI/手册)
CI / Backend (go vet + test) (push) Canceled after 0s
CI / Frontend (lint + build + test) (push) Canceled after 0s

日志数据的保留与安全由对象存储 + Loki retention 承担,平台侧整库备份恢复价值有限:
删除 services/backup.go、/system/{backup,restore,restore/apply,backups} 路由与 handler、
CLI backup/restore 子命令、前端 api 方法与类型;自检所需的 dataDirPath/密钥指纹并入 selfcheck;
用户手册删备份章节并修正 FAQ 升级建议;CHANGELOG 记录移除。
This commit is contained in:
opsx committed 2026-10-29 14:48:25 +08:00
1 parent e07fe55c86
commit f87fb4b2b3
11 files changed
+34 -552

No files matched your search

+24
View File
@@ -1,10 +1,14 @@
package services
import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"lokistack/config"
"net/http"
"os"
"path/filepath"
"strings"
"syscall"
"time"
@@ -263,6 +267,11 @@ func fileDBStats(path string) string {
count("deployments"), count("collectors"), count("auditLogs"))
}
// dataDirPath 数据目录绝对路径(自检磁盘空间等场景使用)
func dataDirPath() string {
return config.GetConfig().DataDir
}
// diskUsage 返回剩余与总空间(字节)
func diskUsage(path string) (free, total uint64, err error) {
var st syscall.Statfs_t
@@ -271,3 +280,18 @@ func diskUsage(path string) (free, total uint64, err error) {
}
return st.Bavail * uint64(st.Bsize), st.Blocks * uint64(st.Bsize), nil
}
// encryptionKeyFingerprint ENCRYPTION_KEY 指纹(SHA256 前 16 位,自检展示用,不泄露密钥)
func encryptionKeyFingerprint() string {
key := config.GetConfig().EncryptionKey
if key == "" {
if b, err := os.ReadFile(filepath.Join(config.GetConfig().DataDir, ".encryption-key")); err == nil {
key = strings.TrimSpace(string(b))
}
}
if key == "" {
return ""
}
sum := sha256.Sum256([]byte(key))
return hex.EncodeToString(sum[:])[:16]
}