done
# Logfile
-LOGFILE=$LOGDIR/debian-mirror.log
+LOGFILE=$LOGDIR/mirror.log
# Get in the right directory and set the umask to be group writable
#
if [ "`find $LOCK -maxdepth 1 -amin -$LOCK_TIMEOUT`" = "" ]; then
# Note: this requires the procps ps; for other ps', adjust as necessary
if ps ax | grep '[r]'sync | grep -q $RSYNC_HOST; then
- echo "stale lock found, but a rsync is still running, aiee!"
+ echo "stale lock found, but a rsync is still running, aiee!" > /dev/stderr
exit 1
else
echo "stale lock found (not accessed in the last $LOCK_TIMEOUT minutes), forcing update!"
# check if we need to sync
if [[ "$TRACE_HOST" != "" ]]; then
- TRACE_FILE=$TO/${TRACE_DIR}/${TRACE_HOST}
- TRACE_PRE_DATE=`ls -al $TRACE_FILE`
- rsync --recursive --times --verbose \
- --address=$ADDRESS \
- $RSYNC_HOST::$RSYNC_DIR/${TRACE_DIR}/ \
- $TO/${TRACE_DIR}/ >> $LOGFILE 2>&1
- TRACE_POST_DATE=`ls -al $TRACE_FILE`
- if [ "$TRACE_PRE_DATE" = "$TRACE_POST_DATE" ]; then
+ TRACE_OLD_TIME=`stat -c%Y $TO/$TRACE_DIR/$TRACE_HOST 2> /dev/null`
+ TRACE_NEW_FILE=/tmp/$RSYNC_HOST_$RSYNC_DIR_$RANDOM
+ nice rsync -tv --address=$ADDRESS \
+ $RSYNC_HOST::$RSYNC_DIR/$TRACE_DIR/$TRACE_HOST \
+ $TRACE_NEW_FILE >> $LOGFILE 2>&1
+ TRACE_NEW_TIME=`stat -c%Y $TRACE_NEW_FILE`
+ rm -f $TRACE_NEW_FILE
+ if [ "$TRACE_OLD_TIME" = "$TRACE_NEW_TIME" ]; then
echo 'Trace file for' $RSYNC_HOST::$RSYNC_DIR \
'unchanged, not rsyncing.' >> $LOGFILE
exit 0
fi
# First sync /pool
-rsync --recursive --links --hard-links --times --verbose \
+nice rsync -rlHtv \
$TMP_EXCLUDE $EXCLUDE $SOURCE_EXCLUDE \
- --address=$ADDRESS \
+ --timeout=3600 --address=$ADDRESS \
$RSYNC_HOST::$RSYNC_DIR/pool/ $TO/pool/ >> $LOGFILE 2>&1
result=$?
if [ 0 = $result ]; then
# Now sync the remaining stuff
- rsync --recursive --links --hard-links --times --verbose --delay-updates --delete-after \
+ nice rsync -rlHtv --delay-updates --delete-after \
--exclude "Archive-Update-in-Progress-${HOSTNAME}" \
--exclude "${TRACE_DIR}/${HOSTNAME}" \
- --address=$ADDRESS \
+ --timeout=3600 --address=$ADDRESS \
$TMP_EXCLUDE $EXCLUDE $SOURCE_EXCLUDE \
$RSYNC_HOST::$RSYNC_DIR $TO >> $LOGFILE 2>&1