feat(ops): 增量备份——binlog 归档脚本与全量位点记录(#19 答复)

- backup_incremental.sh:归档已写完 binlog(tar 拷出+gzip),状态文件对齐序号,有更新才产出,保留 30 天
- backup_full.sh:补 .pos 位点文件(SHOW MASTER STATUS),增量重放的起点锚
- 手册新增增量章节:恢复顺序=全量→binlog 重放,含 mysqlbinlog 缺席镜像的说明

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
liuwenxinandClaude Code committed 2026-10-19 11:22:39 +08:00
1 parent 7008de0c69
commit 35fe37fb0c
3 files changed
+131

No files matched your search

+9
View File
@@ -49,8 +49,17 @@ fi
SIZE="$(du -h "$OUT" | cut -f1)"
echo "备份完成:$(basename "$OUT") ($SIZE)"
# 记录 binlog 位点:增量备份(backup_incremental.sh)与恢复重放的对齐锚点——
# 从「此位点之后」的 binlog 开始重放即为完整增量链
docker exec "$CONTAINER" sh -c \
'mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -N -e "SHOW MASTER STATUS"' > "${OUT}.pos" 2>/dev/null
if [[ -s "${OUT}.pos" ]]; then
echo "binlog 位点:$(awk '{print $1, "pos="$2}' "${OUT}.pos") → $(basename "$OUT").pos"
fi
# 保留 30 天
find "$BACKUP_DIR" -maxdepth 1 -name 'payroll_*.sql.gz' -mtime +30 -print -delete
find "$BACKUP_DIR" -maxdepth 1 -name 'payroll_*.pos' -mtime +30 -print -delete
echo "已清理 30 天前的旧备份"
echo ""