Files
docker-backup/llmdoc/guides/how-to-install.md
Wang Defa 4d00283654 feat: 实现 Docker 备份系统,支持远程一键安装
实现功能:
- 文件夹和 MySQL 容器数据库备份
- tar.gz 压缩和自动清理旧备份
- systemd 定时任务集成
- 远程一键安装脚本(通过 Gitea 仓库)
- 完整的 llmdoc 文档系统

安装方式:
bash <(curl -sL https://gitea.bcde.io/wangdefa/docker-backup/raw/branch/main/install.sh)

配置文件位置:/etc/docker-backup/config.yml
命令:docker-backup, docker-backup-cleanup
2025-12-25 15:02:07 +08:00

101 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 如何安装 Docker Backup
## 1. 系统要求
- **操作系统**Linux推荐 Ubuntu, Debian, CentOS, RHEL, Fedora
- **权限**:需要 root/sudo 权限
- **预安装依赖**
- Docker
- Bash (4.0+)
- 网络工具wget 或 curl
## 2. 一键远程安装
### 2.1 执行安装命令
使用以下命令直接从远程仓库安装:
```bash
bash <(curl -sL https://gitea.bcde.io/wangdefa/docker-backup/raw/branch/main/install.sh)
```
安装脚本会自动完成:
- 检测操作系统类型
- 安装依赖工具yq 等)
- 从远程仓库下载脚本文件
- 安装到系统目录(`/usr/local/bin``/etc/docker-backup`
- 创建配置文件模板
- 配置并启动 systemd 服务
- 启动定时任务
### 2.2 配置备份
1. 编辑配置文件
```bash
sudo vi /etc/docker-backup/config.yml
```
2. 配置关键参数:
- `output_dir`:备份文件存储位置
- `folders.sources`:需要备份的文件夹列表
- `mysql.container_name`MySQL 容器名称
- `retention.keep_days`:备份保留天数
## 3. 高级安装选项
### 3.1 自定义服务名称
```bash
# 为服务指定自定义名称
SERVICE_NAME=my-docker-backup bash <(curl -sL https://gitea.bcde.io/wangdefa/docker-backup/raw/branch/main/install.sh)
```
### 3.2 自定义执行计划
```bash
# 每天早上 6 点执行备份
SCHEDULE="*-*-* 06:00:00" bash <(curl -sL https://gitea.bcde.io/wangdefa/docker-backup/raw/branch/main/install.sh)
# 支持的计划格式:
# "daily" 每天
# "*-*-* 02:00:00" 每天凌晨 2 点
# "Mon *-*-* 02:00:00" 每周一凌晨 2 点
# "*-*-01 02:00:00" 每月 1 号
# "hourly" 每小时
```
## 4. 验证安装
1. 检查服务状态
```bash
systemctl status docker-backup.timer
```
2. 手动测试备份
```bash
docker-backup
```
3. 查看备份文件
```bash
docker-backup-cleanup --list
```
## 5. 卸载
```bash
# 卸载 Docker Backup
bash <(curl -sL https://gitea.bcde.io/wangdefa/docker-backup/raw/branch/main/install.sh) --uninstall
```
## 6. 常见问题
- **权限问题**:确保使用 `sudo` 运行脚本
- **依赖缺失**:脚本会自动尝试安装依赖
- **配置错误**:仔细检查 `backup.yml` 配置
## 7. 建议
- 首次安装后,建议立即测试备份功能
- 定期检查备份日志:`journalctl -u docker-backup.service`
- 根据实际需求调整备份策略