-#! /bin/sh
+#! /bin/bash
-if [[ $# != 3 ]]; then
+if [ $# -lt 3 ]; then
echo 'Usage: sync local_dir rsync_host rsync_dir'
exit 1
fi
RSYNC_DIR=$3
LOGDIR=/var/log/mirror/$1_$2
ADDRESS=129.97.134.71
+EXTRA=$4
mkdir -p $LOGDIR
# uncomment the following lines (and edit the other file).
# . ftpsync.conf
-# export RSYNC_PASSWORD
-# RSYNC_HOST=$RSYNC_USER@$RSYNC_HOST
+export RSYNC_PASSWORD
+if [[ "$RSYNC_USER" != "" ]]; then
+ RSYNC_HOST=$RSYNC_USER@$RSYNC_HOST
+fi
#-----------------------------------------------------------------------------#
TMP_EXCLUDE="--exclude .~tmp~/"
# 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!" >&2
exit 1
else
echo "stale lock found (not accessed in the last $LOCK_TIMEOUT minutes), forcing update!"
set +e
# Now sync the remaining stuff
-rsync --recursive --links --hard-links --times --verbose --delay-updates --delete-after \
+nice rsync -aHv --delete \
--exclude "Archive-Update-in-Progress-${HOSTNAME}" \
- --address=$ADDRESS $TMP_EXCLUDE \
+ --timeout=3600 -4 --address=$ADDRESS $TMP_EXCLUDE $EXTRA \
$RSYNC_HOST::$RSYNC_DIR $TO >> $LOGFILE 2>&1
+if [[ "$?" != "0" ]]; then
+ echo "ERROR: Help, something weird happened" | tee -a $LOGFILE
+ echo "mirroring /pool exited with exitcode" $result | tee -a $LOGFILE
+fi
+chmod ug+rwx $TO
savelog $LOGFILE >/dev/null