To avoid executing the task, Rake needs to know both the target and source and the rule for determining whether to execute the task in order to create the target from the source.

Normally that is rule is "time modified", i.e. if source is newer than target then Rake will run the task. You can modify this by providing a Proc as the source dependency. See http://docs.rubyrake.org/user_guide/chapter03.html under "Advanced Rules" (but it does take some experimentation to get your head around what is happening!).

So your task must depend on the target. If you know the target does not exist it should be easy:

If target exists already it gets much more complicated. You could define a rule for each and every file but frankly I'd just run the rsync and be done with it. Rsync is very fast on local filesystems, running it everytime is just no big deal.