There are a few things that could be going wrong here. First of all, you are missing a semi colon at the end of the $copy
variable declaration. Your script should be
$copy = 'rsync -acz user@server:/home/user/foo.txt .';
shell_exec ($copy);
If that is just a typo in your post and not the way the real script is, make sure you can run the command correctly from a terminal, without needing to enter a password. If you can, launch your php script again but monitor your error logs. Assuming you are running this script through a an apache webserver, that would be
tail -f /var/log/apache2/error.log
which rsync
may be /bin/rsync should work better in script?