#!/bin/sh


lockfile="/tmp/arch-mirror.lock"
if [ -z "$flock" ] ; then
  exec env flock=1 flock -n $lockfile "$0" "$@"
fi


SYNC_SRC=rsync://rsync.archlinux.org/ftp_tier1/
SYNC_DEST="/var/www/si.tux.mirror/arch"



mkdir -p "$SYNC_DEST"

echo "============================================="
echo ">> Starting sync on $(date)"
echo ">> ---"


options="-rtlvuH -4 --delete --delete-after --delete-excluded --prune-empty-dirs --delay-updates --timeout=300"

/usr/bin/rsync $options \
        "$SYNC_SRC" "$SYNC_DEST"



echo ">> ---"
echo ">> Finished sync on $(date)"
echo "============================================="
echo ""

fstrim /var/www/si.tux.mirror/arch

echo "finished fstrim"

exit 0
