rsync errors in tier2 mirrors
It is possible for arch mirrors to be in an inconsistent state if rsync fails at some point. This is due to mirrors not generating their own package databases but rather copying the one from lower tier mirrors. In these cases, trying to grab a package from these mirrors may result in a 404 error due to incomplete syncing. The method described in Tier 2 requirements does not adequately protect this case.
The following code will re-run rsync if it ever fails to ensure mirrors are properly synced.
RET=1 COUNTER=100 until [[ RET -eq 0 && COUNTER -gt 0 ]]; do rsync -rtlH --safe-links --delete-after --progress -h --timeout=600 --contimeout=60 -p \ --delay-updates --no-motd --bwlimit=4096 \ --temp-dir="/tmp" \ --exclude='*.links.tar.gz*' \ --exclude='/other' \ --exclude='/sources' \ --exclude='/iso' \ 'rsync://mirror.pkgbuild.com/packages/' \ "/srv/repo" && RET=0 COUNTER=$[COUNTER-1] done;