I had trouble compiling what you pasted, there appears to be tabs or some other invisible character before the indented lines. I cleared them out & then double escaped the command…
I believe the 'do shell script' command requires you to double escape (the shell expands one backslash, the do shell script expands the other).
tell application "Finder"
activate
do shell script "rsync -ruv --exclude-from=/Volumes/John\\'s\\ Stuff/john/Rsync/Exclude\\from\\Media\\ Storage.txt /Volumes/John\\'s\\ Stuff/john /Volumes/Media\\ Storage\\ 1"
end tell
display dialog "Backup complete, Do you want to eject the disk?"
if result = {button returned:"Ok"} then
try
do shell script "diskutil eject /Volumes/Media\\ Storage\\ 1"
display dialog "Successfully ejected the disk." buttons {"Close"} default button "Close"
on error
display dialog "Unable to eject the disk." buttons {"Close"} default button "Close"
end try
else if result = {button returned:"Cancel"} then
end if
I haven't tested it with rsync, so see if it works for you.
I also made diskutil eject the disk name without the wildcards - you need to double escape that too.
Personally I find it easier to convert to quoted variables and then smash them into a string via '&'…
set source to quoted form of POSIX path of "/Volumes/John's Stuff/john"
set dest to quoted form of POSIX path of "/Volumes/Media Storage 1"
set exclude to quoted form of POSIX path of "/Volumes/John's Stuff/john/Rsync/Exclude from Media Storage.txt"
tell application "Finder"
activate
do shell script "rsync -ruv --exclude-from=" & exclude & " " & source & " " & dest
end tell
display dialog "Backup complete, Do you want to eject the disk?"
if result = {button returned:"Ok"} then
try
do shell script "diskutil eject " & dest
display dialog "Successfully ejected the disk." buttons {"Close"} default button "Close"
on error
display dialog "Unable to eject the disk." buttons {"Close"} default button "Close"
end try
else if result = {button returned:"Cancel"} then
end if
P.S.
See this if you want to automate fixing the broken indenting that this forum does to Applescripts.
Bookmarklet to fix AppleScript pasting on discussions.apple.com