Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e00e4c0
fix(ci): fix Docker GHCR tags, add GUI to macOS/Windows releases, bun…
airprofly Jul 12, 2026
8524f2a
refactor(ci): move Docker registry tag from workflow override to HCL
airprofly Jul 12, 2026
a1b160b
fix(ci): fix publish workflow failures
airprofly Jul 12, 2026
0605c09
fix(ci): specify docker-bake.hcl explicitly to avoid docker-compose.y…
airprofly Jul 12, 2026
1c9dcf4
fix(ci): detect OpenSSL DLL version dynamically on Windows
airprofly Jul 12, 2026
0355bd5
perf(ci): add Docker layer caching to speed up builds
airprofly Jul 12, 2026
bcca2c8
fix(ci): remove unsupported cache flags from docker buildx bake
airprofly Jul 12, 2026
760d2fc
fix(ci): auto-delete existing release before creating new one
airprofly Jul 12, 2026
b99365f
feat(ci): static OpenSSL linking on Windows, remove DLL dependencies
airprofly Jul 12, 2026
abfc60d
feat(ci): add Qt6 GUI to Windows build via aqtinstall
airprofly Jul 12, 2026
a18e470
fix(ci): use vcpkg for Qt6 on Windows, remove aqtinstall
airprofly Jul 12, 2026
26440fc
fix(ci): use correct Qt6 arch identifier for Windows
airprofly Jul 12, 2026
a41621b
perf(ci): add vcpkg binary cache for Windows OpenSSL
airprofly Jul 12, 2026
6c07621
fix(ci): remove invalid --modules qtbase from aqtinstall
airprofly Jul 12, 2026
3b68e44
fix(ci): use install-qt-action for Windows Qt6
airprofly Jul 12, 2026
7b6117f
fix(ci): simplify Windows build - choco OpenSSL + install-qt-action
airprofly Jul 12, 2026
2486bd0
fix(ci): enable Qt6 caching for Windows build
airprofly Jul 12, 2026
fde3606
fix(ci): use windeployqt directly from PATH
airprofly Jul 12, 2026
a02ce80
fix(ci): disable Qt6 auto-download on Linux in publish-release
airprofly Jul 12, 2026
6fc656c
fix(ci): disable Qt6 auto-download on all platforms in publish-release
airprofly Jul 12, 2026
3f4553f
fix(ci): add runner.os to cache keys to prevent cross-platform pollution
airprofly Jul 12, 2026
dd24239
fix(ci): tolerate windeployqt non-zero exit code
airprofly Jul 12, 2026
04fe7a6
fix(ci): disable Qt6 auto-download on Linux in ci.yml
airprofly Jul 12, 2026
96728aa
feat(ci): test GUI build on macOS and Windows in ci.yml
airprofly Jul 12, 2026
a1f4411
fix(ci): reset PowerShell exit code after windeployqt warning
airprofly Jul 12, 2026
7f6e361
fix(ci): copy OpenSSL DLLs to dist on Windows
airprofly Jul 12, 2026
a4e9c0d
fix(ci): use correct OpenSSL 4.x DLL names for Windows package
airprofly Jul 12, 2026
73ed53c
fix(ci): OpenSSL 4.x DLL names are libcrypto-4.dll, not libcrypto-40.dll
airprofly Jul 12, 2026
ae902da
fix(ci): correct OpenSSL 4.x DLL name is libcrypto-4-x64.dll
airprofly Jul 12, 2026
a0f76e5
fix(ci): delete existing tag before creating release to avoid 422 error
airprofly Jul 12, 2026
d0046c3
feat(cli): support human-readable date format for --mtime-* options
airprofly Jul 14, 2026
82f2a46
docs(usage): add feature score summary table
airprofly Jul 14, 2026
516ec18
Merge branch 'main' into release/airprofly_01-v1.0.0
airprofly Jul 14, 2026
5e84741
fix(cli): replace POSIX strptime with standard std::get_time for cros…
airprofly Jul 14, 2026
9134985
docs: overhaul README and add UML diagrams for course report
airprofly Jul 16, 2026
964383b
Merge branch 'main' into release/airprofly_01-v1.0.0
airprofly Jul 16, 2026
b35e6c5
docs: sync project directory tree with current structure
airprofly Jul 16, 2026
1b76c7c
fix(ci): bundle VC++ runtime DLLs in Windows release package
airprofly Jul 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ jobs:
windeployqt dist/backer-gui.exe
if ($LASTEXITCODE -ne 0) { Write-Warning "windeployqt exited with $LASTEXITCODE"; $global:LASTEXITCODE = 0 }
}
# 复制 VC++ 运行时 DLL(避免无 VC++ Redistributable 的机器上无法启动)
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $vswhere) {
$vsInstallDir = & $vswhere -latest -property installationPath
$vcRedistPaths = Resolve-Path "$vsInstallDir\VC\Redist\MSVC\*\x64\Microsoft.VC143.CRT\*" -ErrorAction SilentlyContinue
if ($vcRedistPaths) {
Copy-Item "$(Split-Path $vcRedistPaths[0])\*.dll" dist/
Write-Host "✅ VC++ runtime DLLs copied"
} else {
Write-Warning "⚠ VC++ redist directory not found"
}
} else {
Write-Warning "⚠ vswhere not found, skipping VC++ runtime DLLs"
}
Copy-Item "C:\Program Files\OpenSSL\bin\libcrypto-4-x64.dll" dist/
Copy-Item "C:\Program Files\OpenSSL\bin\libssl-4-x64.dll" dist/
Copy-Item LICENSE dist/
Expand Down
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ assets/
data/
testdata/
output

node_modules/
package-lock.json
package.json
docs/diagrams/dist/*

# ================= latex =================
.build/*
Expand Down Expand Up @@ -58,9 +61,9 @@ ENV/
.cppcheck-cache/

# =============== 日志文件 ===============
logs/
**/logs/
*.log
# logs/
# **/logs/
# *.log

# =============== IDE ===============
# JetBrains
Expand Down
164 changes: 59 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,77 +14,86 @@

## 📖 项目简介

Backer 是计算机组成与体系结构/软件工程课程项目,基于 **C++17** 在 **Linux** 平台开发,使用 **CLI11** 提供命令行接口,**spdlog** 处理日志,**Google Test** 驱动测试
Backer 是一款 **Linux 平台的数据备份还原工具**,采用 **C++17** 开发,支持目录树备份与还原、特殊文件处理、元数据保留、灵活筛选、多格式打包、多算法压缩加密、图形界面与定时备份等完整功能

依赖通过 **CMake FetchContent** 自动拉取(CLI11 v2.4.2、spdlog v1.14.1、GTest v1.15.2),无需手动安装。加密功能依赖系统 OpenSSL(`libssl-dev`,通过 `find_package` 接入)。
## 📁 项目结构

**当前状态**:已完成核心备份/还原、特殊文件、元数据保留、自定义筛选(6 维度)、Tar/Zip 打包、gzip/zstd/lzma 压缩、AES-256-GCM/SM4-CBC 加密、Qt 6 图形界面及**定时备份(Cron 调度 + 数据淘汰)**。后续将通过管道架构扩展实时监控及网络备份等功能。
```text
backer/
├── CMakeLists.txt # 根构建配置(FetchContent 自动拉取依赖)
├── Dockerfile # Multi-stage Docker 构建
├── docker-bake.hcl # Docker Bake 多平台构建
├── docker-compose.yml # Compose 编排
├── .dockerignore # 构建上下文精简
├── .github/ # CI/CD: 三平台构建测试 + 发布 + 镜像推送
├── .claude/ # Claude Code AI 辅助配置
├── .vscode/ # VS Code 编辑器配置
├── .gitignore
├── CLAUDE.md # AI 辅助开发指南
├── LICENSE # Apache 2.0
├── cppcheck-suppressions.txt # 静态分析抑制规则
├── cppcheck-report.txt # 静态分析报告
├── cmake/ # CMake 模块(FetchQt6.cmake)
├── docs/
│ ├── architecture-design.md # 分层架构 + 管道模式
│ ├── requirements.md # 需求规格说明
│ ├── technology-selection.md # 技术选型记录
│ ├── reportDetails.md # 课程报告详情
│ ├── usage.md # 使用文档
│ ├── ppt.md # 课程答辩提纲
│ ├── diagrams/ # 架构图源文件(PlantUML)
│ ├── images/ # 文档配图
│ └── plans/ # 分阶段实现计划
├── src/ # 源代码
│ ├── main.cpp # 程序入口
│ ├── cli/ # 命令行接口 (CLI11)
│ ├── core/ # 备份/还原引擎
│ ├── fs/ # 文件系统抽象层
│ ├── storage/ # 存储抽象层
│ ├── filters/ # 筛选器(6 维度)
│ ├── pack/ # 打包模块(Tar/Zip)
│ ├── compress/ # 压缩模块(gzip/zstd/lzma)
│ ├── crypto/ # 加密模块(AES/SM4)
│ ├── gui/ # Qt 6 图形界面
│ └── scheduler/ # 定时备份
├── tests/ # Google Test 单元测试
├── scripts/ # 辅助脚本
├── logs/ # 测试日志(gtest/ctest/valgrind)
└── data/ # 测试数据(.gitignore)
```

## 🔧 构建与运行
## 🔧 快速开始

**前置要求**:GCC 9+ / Clang 12+、CMake 3.16+

> 加密功能需要系统安装 OpenSSL 开发库(Ubuntu: `sudo apt install libssl-dev`,Fedora: `sudo dnf install openssl-devel`)。CMake 通过 `find_package` 自动检测。

### Linux

```bash
# 构建(CLI 版本,需要 OpenSSL)
sudo apt install libssl-dev # 加密功能依赖 OpenSSL

# 构建(CLI 版本)
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)

# 构建 GUI 版本(需要 Qt6:sudo apt install qt6-base-dev)
cmake -B build -DBUILD_GUI=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)

# 运行测试
ctest --test-dir build --output-on-failure

# 生成测试数据(在 data/source 下创建目录及各类文件)
bash scripts/setup-testdata.sh
# 测试(日志输出到 logs/)
ctest --test-dir build --output-on-failure &>logs/ctest.log
./build/backer_test &>logs/gtest-all.log
valgrind --leak-check=full ./build/backer_test --gtest_filter="*" &>logs/valgrind.log
perf record -g -o logs/perf.data ./build/backer-cli backup data/source data/backup
perf report -i logs/perf.data --stdio >logs/perf.txt

# CLI 使用(测试数据目录备份/还原)
./build/backer-cli backup data/source data/backup
./build/backer-cli restore data/backup data/restore

# 端到端流程测试(交互式选择 Local/Docker)
bash scripts/test-backup-restore.sh

# 仅运行特定测试
./build/backer_test --gtest_filter="*RestoreEngine*"
# CLI 使用(完整命令参考见 [使用文档](docs/usage.md))
./build/backer-cli --help
```

### Docker 构建
### Docker

```bash
# 先准备好测试数据
bash scripts/setup-testdata.sh

# 构建镜像(multi-stage 构建,最终镜像约 100MB)
# 国内用户可添加 --build-arg GH_PROXY=https://ghproxy.net/ 加速依赖下载
docker build -t backer .

# 使用 Compose(含数据卷挂载)进入容器执行备份
docker compose run --rm backer backup /data/source /data/backup

# 查看备份结果(目录已挂载到宿主机)
ls -la data/backup

# 使用 Compose 还原备份
docker compose run --rm backer restore /data/backup /data/restore

# 查看还原结果
ls -la data/restore

# 交互式运行
docker run --rm backer --help
```

`docker-compose.yml` 默认挂载三个数据卷:
- `./data/source:/data/source:ro` — 待备份源目录
- `./data/backup:/data/backup` — 备份输出目录
- `./data/restore:/data/restore` — 还原目标目录

## 📌 规划特性

- ✅ **核心备份/还原** — 目录树递归扫描,文件内容读写,备份索引
Expand All @@ -99,51 +108,7 @@ docker run --rm backer --help
- ✅ **定时备份** — Cron 表达式调度 + 快照数据淘汰
- 🔲 **网络备份** — gRPC + Protocol Buffers 远程备份

## 📁 项目结构

```text
backer/
├── CMakeLists.txt # 根构建配置(FetchContent 自动拉取依赖)
├── Dockerfile # Multi-stage Docker 构建
├── docker-compose.yml # Compose 编排
├── .dockerignore # 构建上下文精简
├── .github/ # CI: workflows/ci.yml(lint → 构建测试 → Valgrind → Docker)
├── .claude/ # Claude Code AI 辅助配置(commands/:implement-feature, test-features, update-info, git 等)
├── cmake/ # CMake 模块(FetchQt6.cmake — Qt6 自动下载)
├── .vscode/ # VS Code 编辑器配置(c_cpp_properties.json)
├── CLAUDE.md # AI 辅助开发指南
├── LICENSE # Apache 2.0
├── docs/
│ ├── architecture-design.md # 分层架构 + 管道模式
│ ├── requirements.md # 需求规格说明
│ ├── technology-selection.md # 技术选型记录
│ ├── reportDetails.md # 课程报告详情
│ └── plans/ # 分阶段实现计划(README + 01~11)
├── src/ # 🔧 源代码
│ ├── main.cpp # 程序入口(CLI 初始化 + 命令派发)
│ ├── cli/ # ✅ 命令行接口 (CLI11)
│ ├── core/ # ✅ 备份/还原引擎(含特殊文件+元数据)
│ ├── fs/ # ✅ 文件系统抽象层(含元数据+特殊文件)
│ ├── storage/ # ✅ 存储抽象层(本地文件系统)
│ ├── filters/ # ✅ 筛选器(6 维度自定义规则)
│ ├── pack/ # ✅ 打包模块(Tar ustar + miniz Zip)
│ ├── compress/ ✅ # 压缩模块(gzip/zstd/lzma 策略接口 + 工厂)
│ ├── crypto/ ✅ # 加密模块(AES-256-GCM / SM4-CBC,基于 OpenSSL EVP)
│ ├── gui/ ✅ # Qt 6 图形界面(自动下载 Qt6)
│ ├── scheduler/ ✅ # 定时备份(cron 调度 + 数据淘汰)
│ ├── watch/ 🔲 # inotify 实时监控
│ └── network/ 🔲 # gRPC 网络备份
├── tests/ # 📝 Google Test 单元测试
├── scripts/ # 辅助脚本(setup-qt6.sh, setup-testdata.sh, test-backup-restore.sh)
└── data/ # 🧪 脚本生成的测试数据(.gitignore)
├── source/ # 源目录(setup-testdata.sh 生成)
├── backup/ # 备份输出
└── restore/ # 还原目标
```

> ✅ = 已完成 🔲 = 待实施

## 🏗️ 架构设计
## 🏗️ 架构设计f

详见 [架构设计文档](docs/architecture-design.md)。

Expand Down Expand Up @@ -189,17 +154,6 @@ git push origin <分支名>
# 6. 在 GitHub 上创建 Pull Request → 待 review 通过后合入 main(合并时务必选择 **Squash and merge**,不要使用 Create a merge commit)
```

### CI/CD

项目配置了 [GitHub Actions CI](.github/workflows/ci.yml),每次推送/PR 自动运行:

| Job | 系统 | 内容 |
|-----|------|------|
| `linux-build` | Ubuntu 22.04 | GCC-12 / Clang-14 双编译器 + Google Test + GUI |
| `macos-build` | macOS 14 | Xcode Clang + Google Test |
| `windows-build` | Windows 2022 | MSVC + Google Test |
| `docker` | Ubuntu 22.04 | Docker 镜像构建验证 |

## 📄 许可证

本项目基于 Apache License 2.0 开源 — 详见 [LICENSE](LICENSE)。
36 changes: 36 additions & 0 deletions docs/diagrams/src/class.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@startuml backer-class
skinparam backgroundColor #FEFEFE
skinparam classBorderColor #2C3E50
skinparam classBackgroundColor #ECF0F1
skinparam arrowColor #2C3E50

class "CLI Commands" {
+ handleBackup(source, dest) : int
+ handleRestore(source, dest) : int
}

class BackupEngine {
+ backup(source, dest) : BackupResult
}

class RestoreEngine {
+ restore(source, dest) : BackupResult
}

class BackupScheduler {
+ addJob(job)
+ run()
}

interface FSAbstraction {
+ {abstract} walk(root)
+ {abstract} read(path)
}

"CLI Commands" --> BackupEngine
"CLI Commands" --> RestoreEngine
"CLI Commands" --> BackupScheduler

BackupEngine --> FSAbstraction
RestoreEngine --> FSAbstraction
@enduml
50 changes: 50 additions & 0 deletions docs/diagrams/src/component.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@startuml backer-component
skinparam backgroundColor #FEFEFE
skinparam componentBorderColor #2C3E50
skinparam componentBackgroundColor #ECF0F1
skinparam arrowColor #2C3E50

title 构件图 - 物理体系结构

package "可执行构件" {
[backer-cli] as CLI_EXE <<executable>>
[backer-gui] as GUI_EXE <<executable>>
}

package "业务逻辑" {
[Backup Engine]
[Restore Engine]
[Backup Scheduler]
}

package "管道构件" {
[Filter Library]
component "Packer Library" {
[Tar]
[Zip]
}
component "Compress Library" {
[Gzip]
[Zstd]
}
component "Crypto Library" {
[AES-256-GCM]
[SM4-CBC]
}
}

package "基础设施" {
[FS Abstraction]
[Metadata Manager]
}

CLI_EXE --> [Backup Engine] : uses
CLI_EXE --> [Backup Scheduler] : uses
GUI_EXE --> [Backup Engine] : uses
[Backup Engine] --> [FS Abstraction] : uses
[Restore Engine] --> [FS Abstraction] : uses
[Backup Engine] --> [Packer Library] : uses
[Backup Engine] --> [Compress Library] : uses
[Backup Engine] --> [Crypto Library] : uses
[Backup Engine] --> [Filter Library] : uses
@enduml
41 changes: 41 additions & 0 deletions docs/diagrams/src/layers.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@startuml backer-layers
skinparam backgroundColor #FEFEFE
skinparam componentBorderColor #2C3E50
skinparam componentBackgroundColor #ECF0F1
skinparam arrowColor #3498DB

title 分层架构

package "表现层" {
[CLI 命令]
[Qt GUI]
}
note right: 入口,调用业务层

package "业务层" {
[备份/还原引擎]
[备份调度器]
}
note right: 编排管道,调度任务

package "管道层" {
[筛选/打包/压缩/加密]
}
note right: 策略接口,按需组合

package "基础设施层" {
[文件系统抽象 / 元数据]
}
note right: 文件读写、元数据、特殊文件

package "存储层" {
[本地存储]
}
note right: 数据持久化

表现层 --> 业务层 : calls
业务层 --> 管道层 : orchestrates
业务层 --> 基础设施层 : uses
业务层 --> 存储层 : reads/writes
管道层 --> 基础设施层 : accesses files
@enduml
Loading
Loading