Files
zhuiguang-ai/scripts/install-cron-backup.sh

23 lines
959 B
Bash
Raw Permalink 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
# =============================================================================
# 追光AI 容器化版 host 备份 cron 安装脚本
# - 在宿主机 crontab 里加 1 条:每天 03:30 跑 backup-volumes.sh
# - 注意:这是宿主机 cron(不是容器内 supercronic)
# - 用法: bash scripts/install-cron-backup.sh
# =============================================================================
set -e
PROJECT="/home/ubuntu/zhuiguang-ai"
SCRIPT="$PROJECT/scripts/backup-volumes.sh"
CRON_LINE="30 3 * * * bash $SCRIPT >> $PROJECT/logs/host-backup.log 2>&1"
if ! crontab -l 2>/dev/null | grep -qF "$SCRIPT"; then
echo "[install-cron-backup] 添加备份 cron: $CRON_LINE"
(crontab -l 2>/dev/null; echo "$CRON_LINE") | crontab -
else
echo "[install-cron-backup] 备份 cron 已存在,跳过"
fi
echo "[install-cron-backup] 当前 crontab 中包含 backup 的行:"
crontab -l 2>/dev/null | grep -E "backup" || echo " (无)"