=== removed file 'snapshot.lvm2' --- snapshot.lvm2 2013-10-25 18:33:33 +0000 +++ snapshot.lvm2 1970-01-01 00:00:00 +0000 @@ -1,34 +0,0 @@ -#!/bin/sh -# usage: snapshot.lvm2 vg/lv executable [args] -SRC="$1" -shift -S_VOL="${SRC}.snaprep" -S_DEV="/dev/${SRC}.snaprep" -SNAPSHOT="/mnt/snaprep/${SRC//\//-}" -export SNAPSHOT -LOCKDIR=/var/lock/snaprep -test -d "$LOCKDIR" || mkdir -p "$LOCKDIR" || exit $? -LOCKFILE="$LOCKDIR/lvm2.${SRC//\//-}" -touch "$LOCKFILE" || exit $? -flock -n 0 <"$LOCKFILE" || exit $? -if test -b "$S_DEV"; then - echo >&2 "removing stale snapshot" - if grep -qF "$S_DEV"; then # TODO match only on start of line - umount $S_DEV || exit $? - fi - lvremove -f "$S_DEV" -fi -if test -d "$SNAPSHOT"; then - # make sure it's empty and unused - rmdir "$SNAPSHOT" -fi -echo $$ >"$LOCKFILE" -mkdir -p "$SNAPSHOT" -lvcreate -n "${SRC##*/}.snaprep" -L "${SNAPSHOT_SIZE:-10G}" -s "$SRC" -mount "$S_DEV" "$SNAPSHOT" -"$@" -RETCODE=$? -umount "$SNAPSHOT" -lvremove -f "$S_VOL" -rm "$LOCKFILE" -exit $RETCODE