date +"%Y-%m-%d %H:%M:%S - $*"
}
-log "$0 begin"
+log "$0 begin $*"
+
+# Make args: $1 [ --exclude=$2 ] when split on :
+rsyncpaths() {
+ local P P0
+ P0="${1%%:*}"
+ echo -n "$P0"
+ rest=false
+ for P in $(echo "$1" | tr : ' ') ; do
+ $rest && echo -n " --exclude=$P"
+ rest=true
+ done
+}
BACKUP=$1
shift
-ERR=false
+ERR=
for D in "$@" ; do
- rsync -aR --delete-after /.$(realpath "$D") $BACKUP/current/.
+ X="/.$(rsyncpaths "$D")"
+ #echo "rsync -aRx --delete-after $X $BACKUP/current/." >> /tmp/timeliner.debug
+ rsync -aRx --delete-after $X $BACKUP/current/.
E=$?
- [ $E != 0 ] && [ $E != 24 ] && ERR="$ERR $D:$E"
+ [ $E != 0 ] && ERR="$ERR $D:$E"
done
-[ -n "$ERR" ] && log "$0 rsync:$ERR - end" && exit 1
+[ -n "$ERR" ] && log "$0 rsync:$ERR"
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" && log "$0 $TODAY exists - end" && exit 0
+cmd test -d "$BASE/$TODAY" && log "$0 $TODAY exists" && 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)" && \
- log "$0 still too early ($SNAPTIME) - end" exit 0
+ log "$0 still too early" && exit 0
-log "make snapshot $TODAY"
+log ".. snapshot $TODAY"
cmd mkdir -p "$BASE/$TODAY"
cmd cp -axl "$BASE/current/." "$BASE/$TODAY/."
log "$0 end"