shift
ERR=false
for D in "$@" ; do
- rsync -aR --delete-after /.$(realpath "$D") $BACKUP/current/. || \
- ERR=true
+ rsync -aR --delete-after /.$(realpath "$D") $BACKUP/current/.
+ E=$?
+ [ $E != 0 ] && [ $E != 24 ] && ERR="$ERR $D:$E"
done
-$ERR && exit 1
+[ -n "$ERR" ] && log "$0 rsync:$ERR - end" && exit 1
HOST="${BACKUP%%:*}"
BASE="${BACKUP#*:}"
+
if [ "$HOST" = "$BACKUP" ] ; then
cmd() { $* ; }
else
TODAY="$(date -d @$TS +%Y-%m-%d)"
# If snapshot of $TODAY exists then exit
-cmd test -d "$BASE/$TODAY" && exit 0
+cmd test -d "$BASE/$TODAY" && log "$0 $TODAY exists - end" && exit 0
# If there is a snap of yesterday and time < SNAPTIME then exit
cmd test -d "$BASE/$(date -d "@$((TS - 86400))" "+%Y-%m-%d")" && \
- test "$TS" -lt "$(date -d "$SNAPTIME" +%s)" && exit 0
+ test "$TS" -lt "$(date -d "$SNAPTIME" +%s)" && \
+ log "$0 still too early ($SNAPTIME) - end" exit 0
-log ".. snapshot $TODAY"
+log "make snapshot $TODAY"
cmd mkdir -p "$BASE/$TODAY"
cmd cp -axl "$BASE/current/." "$BASE/$TODAY/."
log "$0 end"