#!/bin/bash

ARCH_HOME=/vol/linux/archlinux
ARCH_REPO=$ARCH_HOME/repo

BWLIMIT=
#BWLIMIT="--bwlimit=55"

ARCH=i686
#WHAT="0.8 current extra"
WHAT="current"

syncit()
{
    if [ ! -d $ARCH_HOME/backup ] ; then
        mkdir -p $ARCH_HOME/backup
    fi
    if [ ! -d $ARCH_HOME/backup/$1 ] ; then
	mkdir -p $ARCH_HOME/backup/$1
    fi
    if [ ! -d $ARCH_REPO ] ; then
	mkdir -p $ARCH_REPO
    fi
    if [ ! -d $ARCH_REPO/$1 ] ; then
	mkdir -p $ARCH_REPO/$1
    fi

    rsync --verbose --archive --backup \
    --backup-dir=$ARCH_HOME/backup/$1 \
    --delete-after --numeric-ids --compress --stats --progress \
    --filter=". filters" \
    $BWLIMIT \
    rsync://rsync.archlinux.org/$1 \
    $ARCH_REPO/$1
}

for what in $WHAT ; do
    syncit $what
done
