X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;ds=sidebyside;f=sss.sh;h=35b592530c5a7f48a71b47f32b342e937d15766a;hb=f8f64a4df8a634ea536608edb20cb5000de8f286;hp=00c8d1adf7f76d000629a037bd3dac0b8bea6718;hpb=d29b7500ca47b45d751b7ec4915778730b7939aa;p=rrq%2Fnilfs2sss.git diff --git a/sss.sh b/sss.sh index 00c8d1a..35b5925 100755 --- a/sss.sh +++ b/sss.sh @@ -8,6 +8,11 @@ # # The cron bot is expected to run once a minute +# Name of snapshot tag file for "important" snapshots. Format: +# $CNO .... one line for each $CNO that should be preserved as snapshot +# chcp ss $CNO && echo $CNO >> $NAMELIST +NAMELIST=/etc/nilfs2sss.list + # The hour-of-day to preserve as daily snapshot KEEPHH=12 @@ -15,6 +20,8 @@ KEEPHH=12 KEEPDD=15 DEV=$1 +[ "$2" = "all" ] || LSCP="-s" + if [ -z "$DEV" ] ; then DEVS=( $( mount | grep nilfs2 | sed 's/ .*//' ) ) DEV=${DEVS[0]} @@ -34,7 +41,11 @@ YEARLY="$(date -d '-1 year' '+%Y-%m-%d %H:%M:%S')" MARK=( ) function marksnap() { if [[ "${MARK[0]}" == "$1" ]] && [[ "${MARK[1]}" = "$2" ]] ; then - chcp cp $DEV ${MARK[2]} + if [ -r "$NAMELIST" ] && grep -q ^$3 "$NAMELIST" ; then + : # Don't change important snapshots + else + chcp cp $DEV ${MARK[2]} + fi fi MARK=( "$1" "$2" "$3" ) } @@ -42,7 +53,7 @@ function marksnap() { { flock 9 date "+$DEV: %Y-%m-%d %H:%M:%S ---- checking" >&2 - lscp -s $DEV | while read CNO DATE TIME REST ; do + lscp $LSCP $DEV | while read CNO DATE TIME REST ; do TS="$DATE $TIME" [ "$CNO" = "CNO" ] && continue if [[ ! "$TS" > "$YEARLY" ]] ; then