=== modified file 'bin/snap.push.single' --- bin/snap.push.single 2014-02-18 22:49:24 +0000 +++ bin/snap.push.single 2014-02-18 13:43:24 +0000 @@ -7,32 +7,27 @@ if [[ -z $SNAP_SRC ]]; then SNAP_SRC=$1;shift fi -SNAP_SRC=${SNAP_SRC%%/} - if [[ -z $SNAP_DST ]]; then SNAP_DST=$1;shift fi -SNAP_DST=${SNAP_DST%%/} - -rsync=( rsync -aA --delete "$@" ) marks=( $SNAP_SRC/.snapshot.[0-9]*(N) ) (( $#marks != 1 )) && die invalid marks ${(qqq)marks} if [[ $SNAP_DST == *:* ]]; then # remote - $rsync --exclude=/.snapshot.\* $SNAP_SRC/ $SNAP_DST/ && \ - $rsync $SNAP_SRC/ $SNAP_DST/ + rsync -aA --delete "$@" --exclude=/.snapshot.\* $SNAP_SRC/ $SNAP_DST/ && \ + rsync -aA --delete "$@" $SNAP_SRC/ $SNAP_DST/ else # local [[ -d $SNAP_DST ]] || die destination not a directory: ${(qqq)SNAP_DST} - ts=${marks##*.} + ts=${f##*.} snapshots=( ${SNAP_DST}/.snapshot.[1-9]*(N) ) if (($#snapshots)); then link=${SNAP_DST}/${${snapshots[-1]}##*.} - $rsync --link-dest=$link $SNAP_SRC/ $SNAP_DST/$ts/ || exit $? + rsync -aA --link-dest=$link "$@" $SNAP_SRC/ $SNAP_DST/$ts/ || exit $? else - $rsync $SNAP_SRC/ $SNAP_DST/$ts/ || exit $? + rsync -aA "$@" $SNAP_SRC/ $SNAP_DST/$ts/ || exit $? fi touch ${SNAP_DST}/$marks:t fi === modified file 'sbin/snap.lvm2' --- sbin/snap.lvm2 2014-02-18 22:49:24 +0000 +++ sbin/snap.lvm2 2014-02-18 13:43:24 +0000 @@ -1,9 +1,5 @@ #!/bin/sh # usage: snapshot.lvm2 vg/lv executable [args] -if test $# -lt 2; then - echo 'usage: snap.lvm2 vg/lv executable [args]' - exit -fi SRC="$1" shift S_VOL="${SRC}.snaprep" @@ -17,7 +13,7 @@ flock -n 0 <"$LOCKFILE" || exit $? if test -b "$S_DEV"; then echo >&2 "removing stale snapshot" - if grep -qF "$S_DEV" /proc/mounts; then # TODO match only on start of line + if grep -qF "$S_DEV"; then # TODO match only on start of line umount $S_DEV || exit $? fi lvremove -f "$S_DEV" || exit $? @@ -33,8 +29,7 @@ lvremove -f "$S_VOL" exit $? } -magic="$(file -b -s "$(realpath "$S_DEV")")" -case "$magic" in +case file in "$(file -b -s "$S_DEV")"; do (*XFS*) mount -t xfs -o nouuid "$S_DEV" "$SNAPSHOT" || die_lvremove $?;; (*) mount "$S_DEV" "$SNAPSHOT" || die_lvremove $?;; esac