Problem with rsync in AppleScript

Im facing a problem with AppleScript/Rsync.

I try to copy various folders from various drives to one HDD. The following shows a part of the Apple script which is more or less always the same part of code:

tell application "Finder"
    if (disk "MAC SSD X5" exists) then
        do shell script "rsync -azvp '/Volumes/MAC SSD X5' '/Volumes/Backup/MAC SSD X5' --progress --partial  --delete --backup  --backup-dir='/Volumes/Backup/Gelöschte\ Dateien'"
        
    end if
end tell

If I run this in Applescript it works. But uses rsync 2.6.9 which has less functions and less performance.

While if I run:

 rsync -azvp '/Volumes/MAC\ SSD\ X5' '/Volumes/Backup/MAC\ SSD\ X5' --progress --partial  --delete --backup  --backup-dir='/Volumes/Backup/Gelöschte\ Dateien'

directly in the terminal it uses rsync Version 3.2.3 from another folder.

I tried to remove the former Version (2.6.9) of rsync but I didn't succeed.

Also I tried to add

--rsync-path=/usr/bin/local/rsync 

in Applescript. But it still uses rsync 2.6.9. Also if I add the path of the rsync 2.6.9 in Terminal it will uses the new rsync (so the flag is not working either way).

Hope anyone can help me out with this issue.

Thanks in advance!


Solution 1:

  • Run type rsync in Terminal and take note of the path (I assume /usr/local/bin/rsync but this may be different in your case)

  • Call this version of rsync in your AppleScript

    do shell script "/usr/local/bin/rsync -azvp '/Volumes/MAC SSD X5' '/Volumes/Backup/MAC SSD X5' - ...
    

PS: --rsync-path is used to "specify the rsync to run on remote machine" which isn't relevant if you rsync between locally-mounted volumes.