Hi
In fact, you don't need any script for doing this. There is a free tool called rsync, which is available in all linux / Unix platform, to do this. Since it is mostly installed by default, you dont need to install as well. (If it is not, then you need to). rsync work over ssh as well, so it is secured. It does sync only the changes happened on source, so it is fast. It does compression as well.
Thank You