fix(deploy): git pull 后备份脚本不依赖可执行位
db_backup/backup_mysql 改为检测文件存在并用 bash 调用;install_ops_cron 一并 chmod 备份脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+2
-1
@@ -12,10 +12,11 @@ BACKUP_DIR="${NEXUS_BACKUP_DIR:-/var/backups/nexus}"
|
|||||||
RETENTION_DAYS="${NEXUS_BACKUP_RETENTION_DAYS:-30}"
|
RETENTION_DAYS="${NEXUS_BACKUP_RETENTION_DAYS:-30}"
|
||||||
DUMP_SH="${SCRIPT_DIR}/mysql_dump_to_file.sh"
|
DUMP_SH="${SCRIPT_DIR}/mysql_dump_to_file.sh"
|
||||||
|
|
||||||
if [[ ! -x "$DUMP_SH" ]]; then
|
if [[ ! -f "$DUMP_SH" ]]; then
|
||||||
echo "[$(date)] ERROR: missing $DUMP_SH"
|
echo "[$(date)] ERROR: missing $DUMP_SH"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
chmod +x "$DUMP_SH" 2>/dev/null || true
|
||||||
|
|
||||||
mkdir -p "$BACKUP_DIR"
|
mkdir -p "$BACKUP_DIR"
|
||||||
TIMESTAMP="$(date +%Y%m%d_%H%M%S)"
|
TIMESTAMP="$(date +%Y%m%d_%H%M%S)"
|
||||||
|
|||||||
@@ -49,7 +49,11 @@ ensure_crontab() {
|
|||||||
|
|
||||||
ensure_crontab
|
ensure_crontab
|
||||||
|
|
||||||
for f in "${DEPLOY_DIR}/health_monitor.sh" "${DEPLOY_DIR}/db_backup.sh"; do
|
for f in \
|
||||||
|
"${DEPLOY_DIR}/health_monitor.sh" \
|
||||||
|
"${DEPLOY_DIR}/db_backup.sh" \
|
||||||
|
"${DEPLOY_DIR}/mysql_dump_to_file.sh" \
|
||||||
|
; do
|
||||||
if [[ ! -f "$f" ]]; then
|
if [[ ! -f "$f" ]]; then
|
||||||
error "缺少脚本: $f"
|
error "缺少脚本: $f"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -1057,7 +1057,7 @@ backup_mysql() {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
dump_sh="${root}/deploy/mysql_dump_to_file.sh"
|
dump_sh="${root}/deploy/mysql_dump_to_file.sh"
|
||||||
if [[ ! -x "$dump_sh" ]]; then
|
if [[ ! -f "$dump_sh" ]]; then
|
||||||
warn "缺少 $dump_sh,跳过 MySQL 备份"
|
warn "缺少 $dump_sh,跳过 MySQL 备份"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user