File size: 621 Bytes
7a352c6
 
 
4a40ec0
7a352c6
 
 
4a40ec0
7a352c6
4a40ec0
7a352c6
 
 
 
 
4a40ec0
 
 
7a352c6
 
4a40ec0
7a352c6
4a40ec0
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
set -euo pipefail

# 启动 Hindsight
/app/start-all.sh &
HINDSIGHT_PID=$!

# 等待健康
for i in $(seq 1 60); do
    if curl -sf http://localhost:7860/health > /dev/null 2>&1; then
        break
    fi
    sleep 5
done

# 如果存在备份,直接在运行中的 PG 里恢复(不需要重启 Hindsight)
if [ -n "${HF_TOKEN:-}" ]; then
    python3 /opt/backup/restore.py || true
fi

# 定期备份循环
while kill -0 "$HINDSIGHT_PID" 2>/dev/null; do
    sleep "${BACKUP_INTERVAL_SECONDS:-21600}" &
    wait $! || true
    [ -n "${HF_TOKEN:-}" ] && python3 /opt/backup/backup.py scheduled || true
done