Files
deploy.stack/hindsight/backup.job
cnphpbb 9c83f6e2e8 feat(hindsight): 新增 Hindsight 方案三部署 stack
采用 DB+Hindsight 分离部署方案:
- pgvector/pgvector:pg18 向量数据库
- ghcr.nju.edu.cn/vectorize-io/hindsight:latest 应用
- 0.0.0.0:8888/9999 端口绑定
- ~/hindsight/pgdata bind mount (避免 9P fsync 性能)
- HF_CACHE_DIR 参数化,适配非 WSL 环境
- 每日 pg_dump 备份,7 天保留

参考 Obsidian 知识库 DevOps/04-AI工具/Hindsight部署指南.md
2026-06-08 00:05:25 +08:00

26 lines
826 B
Bash
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.
#!/bin/bash
# ============================================================
# Hindsight 备份任务(每日 02:30 跑cron 部署参考 crontab/
# - 热备份docker exec pg_dump 落盘到 bind 挂载的 backups/
# - 保留 7 天的 .sql.gz
# ============================================================
set -euo pipefail
BACKUP_DIR="/home/geng/hindsight/backups"
KEEP_DAYS=7
TS=$(date +%Y%m%d_%H%M%S)
FNAME="hindsight_db_${TS}.sql.gz"
mkdir -p "${BACKUP_DIR}"
docker exec hindsight-db pg_dump \
-U hindsight_user \
-d hindsight_db \
--no-owner --no-privileges \
| gzip > "${BACKUP_DIR}/${FNAME}"
# 清理超过 KEEP_DAYS 天的旧备份
find "${BACKUP_DIR}" -name "hindsight_db_*.sql.gz" -mtime +${KEEP_DAYS} -delete
echo "[backup] ok: ${FNAME} ($(du -h "${BACKUP_DIR}/${FNAME}" | cut -f1))"