#!/bin/sh LOG_FILE="/var/log/qvyun.sync.log" MAX_SIZE=$((10 * 1024 * 1024)) # 10MB in bytes # Clean up old log files find "$(dirname "$LOG_FILE")" -name "$(basename "$LOG_FILE")*" -type f -mtime +7 -delete # Check and rotate log if needed if [ -f "$LOG_FILE" ]; then FILE_SIZE=$(stat -f%z "$LOG_FILE") if [ $FILE_SIZE -gt $MAX_SIZE ]; then mv "$LOG_FILE" "${LOG_FILE}.$(date +%Y%m%d-%H%M%S)" fi fi start_time=$(date "+%Y-%m-%d %H:%M:%S") echo "Start sync at $start_time" >>"$LOG_FILE" /usr/local/bin/qvyun --config /usr/local/etc/qvyun.toml tasks discover --from /mnt/ypl/publish/ --to /mnt/ypl/publish/processed/1 2>&1 >>"$LOG_FILE" /usr/bin/rsync -avh --progress /mnt/ypl/publish/processed/ server.ali.bj.01:/data 2>&1 >>"$LOG_FILE" end_time=$(date "+%Y-%m-%d %H:%M:%S") echo "End sync at $end_time" >>"$LOG_FILE" # Send notification via Gotify /usr/bin/curl -X POST "https://gotify.jdwan.com/message?token=AknNrK_M.ZGqDz5" \ -H "Content-Type: application/json" \ -d "{ \"message\": \"Sync completed from $start_time to $end_time\", \"title\": \"QVYun Sync Status\", \"priority\": 5 }"