added namelist for preserving snapshots selectively
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Fri, 5 Nov 2021 03:50:21 +0000 (14:50 +1100)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Fri, 5 Nov 2021 03:50:21 +0000 (14:50 +1100)
sss.sh

diff --git a/sss.sh b/sss.sh
index 00c8d1adf7f76d000629a037bd3dac0b8bea6718..4c2347cd0b1fdf4bbee27c0a744bccac3365a590 100755 (executable)
--- 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
 
@@ -34,7 +39,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" )
 }