Awuqing 5c896bb96c 修复: 后端审查发现的 5 项问题
根据 Spec + Code Quality 双审查修复:

1. BatchCreate 事务保护(node_service.go/node_repository.go)
   原循环 Create 在 DB 约束失败时会残留半截数据。改为预先构造所有 Node
   再走 repo.BatchCreate 单一事务,任一失败整体回滚。

2. Peek 语义与 Consume 对齐(agent_install_token_repository.go)
   FindByToken 无条件返回任意记录,导致已消费/已过期的僵尸 token
   可通过 compose 端点的 mode 检查但必然 Consume 失败,出现 410 假错。
   新增 FindValidByToken,Peek 改用之。

3. MasterURL / AgentToken / AgentVersion 渲染前校验(installscript/renderer.go)
   防止 YAML 注入(换行/引号逃逸 compose 配置)、shell 注入($(...))、
   非法字符。加 TestRenderScriptRejects* 系列测试覆盖。

4. ipLimiter 无界增长修复(install_handler.go)
   新增 gc 方法 + startGC 后台协程,每 window 周期清理过期 IP 条目。
   RouterDependencies.Context 控制生命周期;app 传入 ctx,测试 t.Cleanup 取消。

5. CreateInstallToken 的 CreatedByID 从 JWT subject 解析(node_handler.go)
   原硬编码 0 导致审计不可追溯。新增 resolveCurrentUserID helper,
   借助 UserRepository 把 JWT subject(用户名)→ user.ID;失败退回 0。
2026-04-19 17:14:17 +08:00
2026-03-17 13:29:09 +08:00
2026-04-01 23:43:12 +08:00
2026-03-17 13:29:09 +08:00

English | 中文

BackupX

Self-hosted server backup management
One binary, one command — manage every backup of every server.

Stars Release Go React SQLite License

Docs · Downloads · Docker Hub


Dashboard Backup Tasks
Storage Targets Backup Records

Highlights

Capability Details
Backup Types Files/directories (multi-source), MySQL, PostgreSQL, SQLite, SAP HANA (full / incremental / differential / log + parallel channels + retry)
SAP HANA Backint Agent Built-in Backint protocol — HANA's native interface routes data directly to any BackupX storage backend
70+ Storage Backends Alibaba OSS, Tencent COS, Qiniu, S3, Google Drive, WebDAV, FTP + SFTP, Azure Blob, Dropbox, OneDrive and dozens more via rclone
Scheduling Cron + visual editor + auto-retention (by days/count + empty-directory cleanup)
Multi-Node Cluster Master-Agent mode via HTTP long-polling — Agents run tasks locally, upload straight to storage, no reverse connectivity required
Security JWT + bcrypt + AES-256-GCM encrypted config + optional backup encryption + full audit log
Notifications Email / Webhook / Telegram on success or failure
Deployment Single binary + embedded SQLite, Docker one-click, zero external dependencies

Quick Start

# Docker (recommended)
docker run -d --name backupx -p 8340:8340 -v backupx-data:/app/data awuqing/backupx:latest

# Or prebuilt archive
curl -LO https://github.com/Awuqing/BackupX/releases/latest/download/backupx-linux-amd64.tar.gz
tar xzf backupx-*.tar.gz && cd backupx-* && sudo ./install.sh

Open http://your-server:8340, create the admin account, then follow the 5-minute Quick Start.

Documentation

The full docs live at https://awuqing.github.io/BackupX/ — Getting Started, Deployment, SAP HANA, Multi-Node Cluster, API reference, and more. Switch to Chinese via the language dropdown in the top-right nav.

Quick links:

Development

git clone https://github.com/Awuqing/BackupX.git && cd BackupX
make dev-server          # Terminal 1 — backend (:8340)
make dev-web             # Terminal 2 — frontend (Vite HMR)
make test                # run all tests
make build               # produce server/bin/backupx + web/dist

See the development guide for more.

Contributing

Issues and pull requests welcome. Please read the contributing guide before opening a PR — commit messages and PRs on this project are written in Chinese.

License

Apache License 2.0

Description
BackupX 是一个面向 Linux / macOS 服务器的自托管备份管理平台。通过企业级 Web 控制台,轻松配置目录备份、数据库备份,并将备份文件安全存储到阿里云 OSS、腾讯云 COS、七牛云 Kodo、Google Drive、S3 兼容存储、WebDAV 或本地磁盘。
Readme 4.5 MiB
Languages
Go 70.1%
TypeScript 27.2%
CSS 1.9%
Shell 0.5%
Dockerfile 0.1%