115 lines
4.4 KiB
Markdown
115 lines
4.4 KiB
Markdown
# Scripts — 部署与运维脚本
|
||
|
||
多站点 Docker 项目的运维脚本集合,涵盖本地开发管理、云服务器运维、云端部署、数据库备份恢复。
|
||
|
||
## 脚本清单
|
||
|
||
### 部署与管理
|
||
|
||
| 脚本 | 用途 | 目标环境 |
|
||
|------|------|---------|
|
||
| `sites-manage-local.sh` | 本地站点启停(npm run dev + Docker) | 本地 |
|
||
| `sites-manage-cloud.sh` | 云服务器站点启停(SSH / 服务器本地运行) | 云端 |
|
||
| `deploy-ai.sh` | 部署站点到 tlyq.ai(txjp 服务器) | 云端 |
|
||
| `deploy-cc.sh` | 部署站点到 tlyq.cc(tgz 服务器) | 云端 |
|
||
| `deploy-monitor.sh` | 独立部署 monitor-ai 告警监控 | 云端 |
|
||
| `edit-site-cc.sh` | www.tlyq.cc 官网内容管理 | 云端 |
|
||
| `check-compliance.sh` | D1-D8 合规检查(LESSONS-LEARNED 自动化) | 本地 |
|
||
|
||
### 备份与恢复(`backup/` 目录)
|
||
|
||
| 脚本 | 用途 | 说明 |
|
||
|------|------|------|
|
||
| `backup/backup.sh` | 统一备份 | --db-only / --full |
|
||
| `backup/restore.sh` | 统一恢复 | --db / --full |
|
||
|
||
> 详细文档见 [backup/README.md](backup/README.md)
|
||
|
||
---
|
||
|
||
## sites-manage-local.sh — 本地站点管理
|
||
|
||
```bash
|
||
bash scripts/sites-manage-local.sh start # 启动全部
|
||
bash scripts/sites-manage-local.sh start ai # 启动 ai 全部
|
||
bash scripts/sites-manage-local.sh start ldap oa # 启动指定站点
|
||
bash scripts/sites-manage-local.sh stop oa # 停止指定站点
|
||
bash scripts/sites-manage-local.sh restart ldap # 重启指定站点
|
||
bash scripts/sites-manage-local.sh status # 查看状态
|
||
```
|
||
|
||
站点启动方式:
|
||
|
||
| 站点 | 方式 | 端口 |
|
||
|------|------|------|
|
||
| ldap | Docker | 6178(Web UI)、3890(LDAP) |
|
||
| oa | `npm run dev`(宿主机) | 6179 |
|
||
| issue | `npm run dev`(宿主机) | 6176 |
|
||
| assets | `npm run dev`(宿主机) | 6177 |
|
||
| monitor | `npm run dev`(宿主机) | 6181 |
|
||
| www / cloud / token | Docker | 6173–6175 |
|
||
|
||
## sites-manage-cloud.sh — 云服务器站点管理
|
||
|
||
```bash
|
||
bash scripts/sites-manage-cloud.sh start ai # 启动全部
|
||
bash scripts/sites-manage-cloud.sh restart nginx # 重启 nginx
|
||
bash scripts/sites-manage-cloud.sh stop oa issue # 停指定站点
|
||
bash scripts/sites-manage-cloud.sh status # 查看状态
|
||
```
|
||
|
||
自动检测运行环境:本地 Mac 运行时通过 SSH 操作 txjp,在云服务器上运行时直接操作本地 Docker。也可显式指定:
|
||
|
||
```bash
|
||
OA_REMOTE=local bash scripts/sites-manage-cloud.sh status # 强制本地模式
|
||
OA_REMOTE=ssh bash scripts/sites-manage-cloud.sh status # 强制 SSH 模式
|
||
```
|
||
|
||
站点全部以 Docker 方式运行,依赖关系:`ldap → oa / issue / assets → nginx`。
|
||
|
||
## deploy-ai.sh — tlyq.ai 部署
|
||
|
||
```bash
|
||
bash scripts/deploy-ai.sh # 自动检测:增量 or 完整构建
|
||
bash scripts/deploy-ai.sh --force # 强制完整构建
|
||
bash scripts/deploy-ai.sh --restart # 仅重启容器
|
||
```
|
||
|
||
交互式选择站点(1–10):www / cloud / token / issue / assets / oa / ldap / gitea / sso / monitor。
|
||
|
||
流程:源码打包 → 上传 → 服务器 `npm install` → `npm run build` → 容器重建。部署后自动验证。
|
||
|
||
LDAP 部署特殊处理:上传 Dockerfile + docker-compose.yml,自动创建 .env,去除端口映射,`--build` 构建含 sqlite3 的镜像。
|
||
|
||
## backup/ — 备份与恢复
|
||
|
||
```bash
|
||
# 站点完整备份(推荐)
|
||
bash scripts/backup/backup.sh # 备份所有
|
||
bash scripts/backup/backup.sh assets monitor # 指定站点
|
||
bash scripts/backup/backup.sh --db-only # 仅数据库
|
||
bash scripts/backup/backup.sh --full # 灾难备份
|
||
bash scripts/backup/backup.sh --local # 本地模式(在服务器上直接运行)
|
||
|
||
# 恢复
|
||
bash scripts/backup/restore.sh # 交互式
|
||
bash scripts/backup/restore.sh --db issue file.db # 数据库恢复
|
||
bash scripts/backup/restore.sh --full backup.tar # 灾难恢复
|
||
bash scripts/backup/restore.sh --local --full ... # 本地灾难恢复(新服务器)
|
||
|
||
备份内容:数据库 + 上传文件 + 配置文件 + nginx + SSL 证书
|
||
|
||
> 详细文档见 [backup/README.md](backup/README.md)
|
||
|
||
## 备份存储路径
|
||
|
||
| 位置 | 路径 |
|
||
|------|------|
|
||
| 云端持久备份 | `/root/docker/db-backups/` |
|
||
| 本地备份 | `db-backups/` |
|
||
|
||
## 依赖
|
||
|
||
- **本地**:macOS / Linux,bash,ssh(配置 `txjp` 和 `tgz` 别名),scp,docker,sqlite3
|
||
- **云端**:Docker Compose,Node.js,better-sqlite3
|