| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #!/bin/bash
- # ------------------------------
- # CONFIGURATION
- # ------------------------------
- SRC="/media/yazoo/nextcloud_files/apex/larry/" # Source directory (note trailing slash)
- DEST="/media/yazoo/Crucial-1T/restore_test_duplicati/files_larry/" # Destination directory
- # Optional: Log file
- LOG_FILE="/var/log/rsync-backup-larry.log"
- # ------------------------------
- # ROOT CHECK
- # ------------------------------
- if [ "$EUID" -ne 0 ]; then
- echo "❌ ERROR: This script must be run as root (use 'sudo $0')." >&2
- exit 1
- fi
- # ------------------------------
- # RUN SYNC
- # ------------------------------
- echo "[$(date)] Starting rsync from $SRC to $DEST..." | tee -a "$LOG_FILE"
- rsync -aAXv \
- --info=progress2 \
- "$SRC" \
- "$DEST" \
- 2>&1 | tee -a "$LOG_FILE"
- if [ $? -eq 0 ]; then
- echo "[$(date)] SUCCESS: Sync completed." | tee -a "$LOG_FILE"
- else
- echo "[$(date)] ERROR: Sync failed." | tee -a "$LOG_FILE"
- exit 1
- fi
|