#!/bin/sh
-RSYNCBIN="/usr/bin/rsync"
-RSYNCOPTS="--archive \
- --contimeout=60 \
- --delete-after \
- --delete-excluded \
- --exclude=lost+found \
- --hard-links \
- --no-motd \
- --partial-dir=.partial \
- --sparse \
- --timeout=60 \
- --verbose"
-SCRIPTDATE=$(date +%Y%m%d%H)
-SCRIPTNAME=$(basename $0)
+SCRIPT_NAME=$(basename $0)
+RSYNC_BINARY="/usr/bin/rsync"
+RSYNC_OPTIONS="--archive \
+ --chmod=Fgo+r \
+ --contimeout=60 \
+ --delete-after \
+ --delete-excluded \
+ --exclude=lost+found \
+ --hard-links \
+ --log-file=/var/log/rsync.log \
+ --log-file-format=\"%o %m %f %l\" \
+ --no-motd \
+ --partial-dir=.partial \
+ --sparse \
+ --timeout=60"
-if [ "$SCRIPTNAME" = "rsyncbackup.sh" ]
+if [ "$SCRIPT_NAME" = "cron.rsyncbackup.sh" ]
then
- RSYNCOPTS="$RSYNCOPTS --progress"
+ RUNNING_FROM_CRON=1
+else
+ RUNNING_FROM_CRON=0
fi
-RSYNC="$RSYNCBIN $RSYNCOPTS"
+if [ $RUNNING_FROM_CRON -eq 1 ]
+then
+ echo
+ echo "================================="
+ echo "==== $SCRIPT_NAME ===="
+ echo "================================="
+ /usr/bin/date >/lxc/filesystems/state
+fi
+
+RSYNC="$RSYNC_BINARY $RSYNC_OPTIONS"
+
-TARGETHOST=store.10g.useribm.hu
-TARGETMODULE=backup
-echo "Syncing module lxc-filesystems to $TARGETHOST"
+TARGET_HOST=store.10g.useribm.hu
+TARGET_MODULE=backup
+echo "Syncing module lxc-filesystems to $TARGET_HOST"
date
-$RSYNC /lxc/filesystems/ ${TARGETHOST}::$TARGETMODULE/lxc-filesystems
+echo $RSYNC /lxc/filesystems/ ${TARGET_HOST}::$TARGET_MODULE/lxc-filesystems >/tmp/rsync.$$
+bash /tmp/rsync.$$
RSYNC_RC=$?
TRIES=1
while [ $RSYNC_RC -ne 0 ]
fi
echo
echo "${TRIES}. retry"
- $RSYNC /lxc/filesystems/ ${TARGETHOST}::$TARGETMODULE/lxc-filesystems
+ bash /tmp/rsync.$$
RSYNC_RC=$?
TRIES=$(( $TRIES + 1 ))
done
+rm --force /tmp/rsync.$$
date
echo