rsync_nc_vols.sh 771 B

12345678910111213141516171819202122232425262728293031
  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. # RUN SYNC
  11. # ------------------------------
  12. echo "[$(date)] Starting rsync from $SRC to $DEST..." | tee -a "$LOG_FILE"
  13. sudo rsync -aAXv \
  14. --delete \
  15. "$SRC" \
  16. "$DEST" \
  17. 2>&1 | tee -a "$LOG_FILE"
  18. if [ $? -eq 0 ]; then
  19. echo "[$(date)] SUCCESS: Sync completed." | tee -a "$LOG_FILE"
  20. else
  21. echo "[$(date)] ERROR: Sync failed." | tee -a "$LOG_FILE"
  22. exit 1
  23. fi