This is a script i used for mirroring Fedora 12 packages and updates, see previous post for Using Rsync. This script using flock program for synchronization mechanism. It was written by a Linux's Kernel hacker H. Peter Anvin. He was also famous as syslinux writer and maintainer.
http://pastebin.com/raw.php?i=7qsARenC