X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=sss.sh;h=35b592530c5a7f48a71b47f32b342e937d15766a;hb=refs%2Fheads%2Fmaster;hp=cda1b1b1124a67702c5cfa8a4aa730ff13f2f235;hpb=ee98f24980136e74e7e6a617a9cea67d2e001761;p=rrq%2Fnilfs2sss.git diff --git a/sss.sh b/sss.sh index cda1b1b..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,30 +41,34 @@ 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 ${MARKYEAR[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 ) + MARK=( "$1" "$2" "$3" ) } { 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 + if [[ ! "$TS" > "$YEARLY" ]] ; then marksnap YEAR "${DATE:0:4}" $CNO - elif [[ "$TS" > "$MONTHLY" ]] ; then + elif [[ ! "$TS" > "$MONTHLY" ]] ; then marksnap MONTH "${DATE:5:2}" $CNO - elif [[ "$TS" > "$WEEKLY" ]] ; then + elif [[ ! "$TS" > "$WEEKLY" ]] ; then # For older than most recent week, keep last snapshot each week marksnap WEEK "$(( 7${DATE:8:2} / 7 - 100 ))" $CNO - elif [[ "$TS" > "$DAILY" ]] ; then + elif [[ ! "$TS" > "$DAILY" ]] ; then marksnap DAY "${DATE:8:2}" $CNO - elif [[ "$TS" > "$HOURLY" ]] ; then + elif [[ ! "$TS" > "$HOURLY" ]] ; then marksnap HOUR "${DATE:8:2}-${TIME:0:2}" $CNO else - echo "$CNO $DATE $TIME within last hour" + : # echo "$CNO $DATE $TIME within last hour" fi done | if read X ; then : # snapshot within last hour