你观察得非常对 👍
Restic 的备份确实看起来像“散装数据”,不像 tar.gz 那样一个完整文件。但这是它的设计特点,而不是问题。
核心思想是:
restic 仓库 = 去重 + 分块 + 加密 的数据存储
所以你看到的:
repo/
├── config
├── data
│ ├── 00
│ ├── 01
│ ├── ...
├── index
├── snapshots
其实是 分块存储的数据对象库(类似 Git 对象库)。
优点:
- 增量备份
- 自动去重
- 节省空间
- 多版本恢复
下面我讲 服务器完全挂掉后的恢复流程。
一、服务器损坏后的恢复流程
假设你的备份在:
S3
└── restic
新服务器恢复步骤只有 4 步。
二、新服务器安装 Restic
安装 Restic
例如:
apt install restic
或
pacman -S restic
三、配置仓库地址
和备份时一样。
例如你用 rclone
export RESTIC_REPOSITORY="rclone:cstbk:restic"
export RESTIC_PASSWORD_FILE="/root/.restic_pass"
四、查看备份历史
运行:
restic snapshots
输出类似:
ID Time Paths
------------------------------------------------
a1b2c3 2026-03-10 /opt/trilium/data
d4e5f6 2026-03-11 /opt/trilium/data
这就是 备份时间点。
五、恢复数据
恢复最新备份:
restic restore latest --target /
恢复指定目录:
restic restore latest --target /restore
例如:
restic restore latest --target /restore
恢复后:
/restore/opt/trilium/data
六、恢复完整服务器数据
如果你备份了:
/etc
/home
/opt
恢复:
restic restore latest --target /
服务器数据就回来了。
七、恢复单个目录
例如只恢复 Trilium:
restic restore latest \
--target / \
--include /opt/1panel/apps/trilium
八、恢复单个文件
例如:
restic restore latest \
--target /restore \
--include /etc/nginx/nginx.conf
九、恢复示意
备份时:
/opt/trilium/data
/home
/etc/nginx
恢复时:
restic restore latest --target /restore
得到:
/restore
├── opt
│ └── trilium
├── home
└── etc
十、Restic 为什么不用 tar
因为 tar 的问题:
| tar | restic |
|---|---|
| 每次全量 | 增量 |
| 单文件 | 分块 |
| 无版本 | 多版本 |
| 恢复慢 | 恢复快 |
例如:
500GB 数据
每天改 10MB
tar:
每天 500GB
restic:
每天 10MB
十一、验证备份是否可恢复
Restic提供:
restic check
会检查:
- 数据完整性
- 数据块
- 快照
输出:
no errors were found
十二、Restic 可以当“时间机器”
挂载仓库:
restic mount /mnt/restic
你会看到:
/mnt/restic
└── snapshots
├── 2026-03-10
├── 2026-03-11
可以浏览历史版本。
十三、真实运维恢复流程
真实服务器挂了通常这样恢复:
1 安装系统
2 安装 restic
3 配置 rclone
4 restic restore latest
5 启动服务
恢复时间:
几十GB → 几分钟
几百GB → 几十分钟
十四、Restic + S3 架构
最终结构:
服务器
│
├── restic
│
└── S3对象存储
└── restic repo
恢复只需要:
密码 + restic
💡最后告诉你一个 很多人忽略但非常重要的 Restic 技巧:
你可以 导出一个完整 tar 备份(应急用):
restic dump latest /opt/trilium/data | tar -czf backup.tar.gz -
这样你同时拥有:
restic增量备份
+
传统tar备份
很多运维都会这样做,作为 灾难恢复保险。
正文完