chore(release): script database backup runbook
This commit is contained in:
@@ -31,7 +31,19 @@
|
||||
|
||||
## 3. 数据库备份
|
||||
|
||||
生产 Alembic 升级前必须创建数据库备份:
|
||||
生产 Alembic 升级前必须创建数据库备份。优先使用脚本:
|
||||
|
||||
```bash
|
||||
BACKUP_ROOT=/root/xiaoxia-backups \
|
||||
POSTGRES_CONTAINER=xiaoxia-postgres \
|
||||
POSTGRES_USER=xiaoxia \
|
||||
POSTGRES_DB=xiaoxia_saas \
|
||||
scripts/backup_postgres.sh
|
||||
```
|
||||
|
||||
脚本会输出备份目录,并写入 `manifest.txt` 与 `alembic_version.txt`。
|
||||
|
||||
手动等价命令:
|
||||
|
||||
```bash
|
||||
BACKUP_DIR=/root/xiaoxia-backups/$(date +%Y%m%d-%H%M%S)
|
||||
@@ -94,6 +106,12 @@ docker exec xiaoxia-postgres psql -U xiaoxia -d xiaoxia_saas -Atc 'select versio
|
||||
|
||||
## 7. 回滚策略
|
||||
|
||||
生成恢复计划(不会自动恢复数据库):
|
||||
|
||||
```bash
|
||||
scripts/restore_postgres_plan.sh /root/xiaoxia-backups/<backup-dir>
|
||||
```
|
||||
|
||||
应用回滚:
|
||||
|
||||
- 若数据库未发生不可逆迁移,优先回滚到上一稳定 tag 并重新部署。
|
||||
@@ -104,7 +122,7 @@ docker exec xiaoxia-postgres psql -U xiaoxia -d xiaoxia_saas -Atc 'select versio
|
||||
- Alembic downgrade 只有在 revision 明确支持且已验证时才能执行。
|
||||
- 首次生产接入阶段默认使用备份恢复作为最终兜底。
|
||||
- 恢复前必须二次确认备份路径、目标数据库、停机窗口。
|
||||
- 恢复步骤需按生产数据库实际容器名、DB 名、volume 策略另写一次性 runbook;不要在紧急状态下即兴拼命令。
|
||||
- 恢复步骤必须先由 `scripts/restore_postgres_plan.sh` 生成并复核,不允许紧急状态下即兴拼命令。
|
||||
|
||||
## 8. 发布记录
|
||||
|
||||
|
||||
Reference in New Issue
Block a user