rsync_nc_vols-larry.sh 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # ------------------------------
  3. # CONFIGURATION
  4. # ------------------------------
  5. SRC="/media/yazoo/nextcloud_files/apex/larry/" # Source directory (note trailing slash)
  6. DEST="/media/yazoo/Crucial-1T/restore_test_duplicati/files_larry/" # Destination directory
  7. # Optional: Log file
  8. LOG_FILE="/var/log/rsync-backup-larry.log"
  9. # ------------------------------
  10. # ROOT CHECK
  11. # ------------------------------
  12. if [ "$EUID" -ne 0 ]; then
  13. echo "❌ ERROR: This script must be run as root (use 'sudo $0')." >&2
  14. exit 1
  15. fi
  16. # ------------------------------
  17. # RUN SYNC
  18. # ------------------------------
  19. echo "[$(date)] Starting rsync from $SRC to $DEST..." | tee -a "$LOG_FILE"
  20. rsync -aAXv \
  21. --info=progress2 \
  22. "$SRC" \
  23. "$DEST" \
  24. 2>&1 | tee -a "$LOG_FILE"
  25. if [ $? -eq 0 ]; then
  26. echo "[$(date)] SUCCESS: Sync completed." | tee -a "$LOG_FILE"
  27. else
  28. echo "[$(date)] ERROR: Sync failed." | tee -a "$LOG_FILE"
  29. exit 1
  30. fi