commit 6049602cda8a23863eaa3c812fe6611b3b0723a9 parent 3292774151bb3be7d89c00bde648c924323accbf Author: Jan Pobrislo <ccx@webprojekty.cz> Date: Wed, 5 Nov 2014 01:39:57 +0100 support snapshotting readonly paths by redirecting SNAP_WRITESRC to different directory Diffstat:
| M | bin/snap.marked | | | 10 | ++++++---- |
| M | bin/snap.push.single | | | 8 | +++++--- |
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/bin/snap.marked b/bin/snap.marked @@ -14,15 +14,17 @@ die() { test $# -gt 1 || usage SNAP_SRC="$1" -export SNAP_SRC +: ${SNAP_WRITESRC:=$SNAP_SRC} +export SNAP_SRC SNAP_WRITESRC shift test -d "$SNAP_SRC" || die "not a directory: $SNAP_SRC" -LOCKFILE="$SNAP_SRC/.snaprep" +test -d "$SNAP_WRITESRC" || die "not a directory: $SNAP_WRITESRC" +LOCKFILE="$SNAP_WRITESRC/.snaprep" touch "$LOCKFILE" || exit $? flock -n 0 <"$LOCKFILE" || exit $? echo $$ >"$LOCKFILE" || exit $? -rm -f "$SNAP_SRC"/.snapshot.[0-9]* 2>/dev/null -mark="$SNAP_SRC/.snapshot.$(date +%s)" +rm -f "$SNAP_WRITESRC"/.snapshot.[0-9]* 2>/dev/null +mark="$SNAP_WRITESRC/.snapshot.$(date +%s)" touch "$mark" || exit $? "$@" diff --git a/bin/snap.push.single b/bin/snap.push.single @@ -31,8 +31,10 @@ if test -z "$SNAP_DST"; then usage fi +: ${SNAP_WRITESRC:=$SNAP_SRC} + check_local() { - for m in $SNAP_SRC/.snapshot.[0-9]*; do + for m in $SNAP_WRITESRC/.snapshot.[0-9]*; do test -f "$m" || continue test -n "$mark" && die "duplicate snapshot mark" mark=$m @@ -60,8 +62,8 @@ push_remote() { (*.push) ;; (*) SNAP_DST=${SNAP_DST}.push;; esac - rs "$@" --exclude=/.snapshot.\* "$SNAP_SRC/" "$SNAP_DST/" && \ - rs "$@" "$SNAP_SRC/" "$SNAP_DST/" + rs "$@" --exclude=/${mark##*/} "$SNAP_SRC/" "$SNAP_DST/" && \ + rs "$@" "$SNAP_WRITESRC/${mark##*/}" "$SNAP_DST/" } push_local() {