Wu Qing 1a699da8d6 修复: #46 Agent 一键安装脚本在 Debian dash 下执行失败 (#48)
* 修复: #46 Agent 一键安装脚本在 Debian dash 下执行失败

根因(多因素,任何一个都可能导致用户复现的 "sh: 2: Syntax error: newline unexpected"):
- Debian/Ubuntu 默认 /bin/sh → dash;pipe 方式下 shebang 被忽略
- Content-Type: text/x-shellscript 会触发部分 CDN/反向代理的脚本识别与改写
- 如果响应被改写为 HTML,sh 在第 2 行(<html>)即报此语法错误

修复:
1. 前端命令改为 `curl -fsSL URL | sudo bash`(避开 dash)
2. 命令面板增加"先下载再执行"备用命令(代理过滤场景兜底)
3. install handler Content-Type 改为 text/plain;加 nosniff / no-store /
   Content-Disposition 三头,减少中间层改写的概率
4. 脚本模板加 magic marker `BACKUPX_AGENT_INSTALL_V1`,用户可通过
   `head -3` 自查响应完整性;加 bash 自举段,文件执行时优先切到 bash

测试:
- installscript/issue46_test.go 断言 magic + bash-bootstrap 存在于三种模式
- install_flow_test.go 断言新 headers 与 marker
- go test ./... 全绿,前端 build 通过

* 修复: #46 用户截图证实 nginx SPA fallback 返回 index.html

用户反馈截图显示 curl 下载到的是 BackupX 前端 HTML,而非 shell 脚本——
说明 /install/:token 未被反向代理转发到后端,nginx 按 try_files fallback
到 /index.html,sh 读第 2 行 <html> 报语法错误。

真正的根因修复:
1. 后端 install 端点额外暴露 /api/install/:token 别名,让反向代理
   已有的 /api/ 转发规则自动接管
2. 节点创建时返回的 url/composeUrl 统一使用 /api/install/ 前缀
3. 更新 deploy/nginx.conf 模板:
   - 新增 location /install/ 转发(兼容旧版本生成的命令)
   - 新增 /health /ready /metrics 单独转发,避免 SPA fallback

测试:
- install_flow_test.go 新增 TestInstallScriptAliasUnderAPI 断言
  /api/install/:token 路径可用 + 新生成的 url 用 /api/install/ 前缀
2026-04-20 23:35:39 +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
Observability Prometheus /metrics endpoint + /health + /ready probes + SLA breach gauge
Audit Webhook HMAC-SHA256 signed forwarding to SIEM / WORM storage for compliance (SOC2 / GDPR)
Flow Control Per-node bandwidth cap + per-node concurrency limit — tune big/small nodes independently
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 3.8 MiB
Languages
Go 68.9%
TypeScript 28.2%
CSS 2%
Shell 0.5%
Dockerfile 0.2%