2010-03-07 12:21:40 -05:00
|
|
|
#!/bin/bash -e
|
2007-11-07 20:06:11 -05:00
|
|
|
|
2009-03-25 15:57:48 -04:00
|
|
|
if [ $# -lt 3 ]; then
|
2021-08-17 19:23:45 -04:00
|
|
|
echo 'Usage: sync local_dir rsync_host rsync_dir [password file]'
|
2007-11-07 20:06:11 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-03-07 12:21:40 -05:00
|
|
|
umask 002
|
2007-11-07 20:06:11 -05:00
|
|
|
|
2010-03-07 12:21:40 -05:00
|
|
|
TO=/mirror/root/$1
|
2007-11-07 20:06:11 -05:00
|
|
|
RSYNC_HOST=$2
|
|
|
|
RSYNC_DIR=$3
|
2021-08-17 19:23:45 -04:00
|
|
|
RSYNC_PASSWORD_ARGS=
|
|
|
|
if [ $# -ge 4 ]; then
|
|
|
|
RSYNC_PASSWORD_ARGS="--password-file $HOME/passwords/$4"
|
|
|
|
fi
|
|
|
|
ADDRESS=$(cat ~/config/ADDRESS)
|
|
|
|
|
2010-03-07 12:21:40 -05:00
|
|
|
if test -n "$RSYNC_USER"; then
|
|
|
|
RSYNC_HOST=$RSYNC_USER@$RSYNC_HOST
|
2007-11-07 20:06:11 -05:00
|
|
|
fi
|
|
|
|
|
2021-08-17 19:23:45 -04:00
|
|
|
mkdir -p $TO
|
|
|
|
|
|
|
|
exec nice rsync -aH --no-owner --no-group --delete-after --delay-updates --safe-links \
|
|
|
|
--timeout=3600 -4 --address=$ADDRESS \
|
2010-03-07 12:21:40 -05:00
|
|
|
--exclude .~tmp~/ \
|
|
|
|
--quiet --stats --log-file=/home/mirror/merlin/logs/transfer.log \
|
2021-08-17 19:23:45 -04:00
|
|
|
$RSYNC_PASSWORD_ARGS \
|
|
|
|
rsync://$RSYNC_HOST/$RSYNC_DIR $TO
|
|
|
|
#$RSYNC_HOST::$RSYNC_DIR $TO
|