#!/usr/bin/env bash
. /mirror/lib/sync.sh

set -e

#HOSTNAME=`hostname -f`
HOSTNAME=kr.archive.ubuntu.com

# first, download actual packages
sudo nice -n -4 sudo -u mirror \
    rsync -4 --recursive --times --links --safe-links --hard-links \
    --verbose --stats \
    --exclude "Packages*" --exclude "Sources*" \
    --exclude "Release*" --exclude "InRelease" \
    --exclude ".~tmp~" \
    $source data/

# then, download the indexes
sudo nice -n -4 sudo -u mirror \
    rsync -4 --recursive --times --links --safe-links --hard-links \
    --verbose --stats --delete --delete-after \
    --exclude "project/trace/$HOSTNAME" \
    --exclude ".~tmp~" \
    $source data/

# timestamp
date -u >data/project/trace/$HOSTNAME

ssh 210.117.237.34 '/mirror/ubuntu.sh'
