If it's throwing an error when setting the rsync flags, you can try commenting out the if clause except for the lines you need to use (the ones that set the flags for rsync 2).
That's done for you in this version of the script:
If that version still has problems, let me know what error it returns and I'll see what else I can come up with.