Process log improvements; avoid abort on rsync reporting "vanished files" v0.1.1
authorRalph Ronnquist <rrq@rrq.au>
Sat, 15 Jun 2024 06:30:18 +0000 (16:30 +1000)
committerRalph Ronnquist <rrq@rrq.au>
Sat, 15 Jun 2024 06:30:18 +0000 (16:30 +1000)
timeliner

index e0710aeed1757fdfb40b3bc2aaf529388c039165..5ca3d4687745a4dd76860c9a924191f6574f2bcd 100755 (executable)
--- a/timeliner
+++ b/timeliner
@@ -35,13 +35,15 @@ BACKUP=$1
 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
@@ -52,13 +54,14 @@ TS=$(date +%s)
 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"