#!/bin/sh -e RSYNC_HOST=merkel.debian.org RSYNC_DIR=debian TO=/home/ajt/scratch/debian-i386 MAX_DEL=1000 HOSTNAME=$(hostname -f) LOCK="${TO}/Archive-Update-in-Progress-${HOSTNAME}" if lockfile -! -l 43200 -r 0 "$LOCK"; then echo ${HOSTNAME} is unable to start rsync, lock file exists exit 1 fi tmp=$(tempfile) trap "rm -f $tmp $LOCK > /dev/null 2>&1" exit rsync --links --hard-links --times --verbose --recursive --delay-updates \ --files-from :indices/files/typical.files \ rsync://$RSYNC_HOST/$RSYNC_DIR/ $TO/ ( cd $TO find . \! -type d | sort -u > $tmp sort -u < indices/files/typical.files | diff $tmp - | sed -n 's/^< //p' | grep -v '^\./project/trace/' | head -n $MAX_DEL | xargs rm find -type d -empty | xargs rmdir ) date -u > ${TO}/project/trace/${HOSTNAME}