Fix rclone sync script

This commit is contained in:
Sebastian Cabrera 2025-04-13 23:17:17 -04:00
parent 2fceb0c6bd
commit 2a2ee511f3
No known key found for this signature in database

View file

@ -1,11 +1,19 @@
#!/bin/bash
# Set timezone to US Eastern (handles both EST and EDT correctly)
export TZ="America/New_York"
# Define source and destination
SOURCE="$HOME/files/media"
DEST="goji-hetzner:"
# Log file path
LOGFILE="$HOME/rclone-sync.log"
# Create timestamped log file
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
LOGFILE="$HOME/logs/rclone-sync-$TIMESTAMP.log"
# Run rclone sync and log output to both stdout and file
/usr/bin/rclone sync "$SOURCE" "$DEST" --log-level=INFO 2>&1 | tee -a "$LOGFILE"
# Run rclone and log output to both screen and file using tee (no --log-file!)
{
echo "=== rclone sync started at $(date) ==="
/usr/bin/rclone sync "$SOURCE" "$DEST" --log-level=INFO
echo "=== rclone sync finished at $(date) ==="
} 2>&1 | tee "$LOGFILE"