Skip to content

Instantly share code, notes, and snippets.

@Egregius
Created February 15, 2020 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Egregius/3fc5afef60f91de7a141d9efc010fbc9 to your computer and use it in GitHub Desktop.
Save Egregius/3fc5afef60f91de7a141d9efc010fbc9 to your computer and use it in GitHub Desktop.
Synology btrfs snapshots when needed.
#!/bin/sh
NOW=$(date +"%Y-%m-%d")
BPATH=/volume1/Guy/log
RUNLOG=/volume1/Guy/log/$NOW.txt
NAME="Guy"
echo ------------------- START SNAPSHOT $NAME -- $(date) | tee -a $RUNLOG
SOURCE="/volume1/$NAME"
LAST=$(find $SOURCE -type d -name '#snapshot' -prune -o -type d -name 'log' -prune -o -type f -printf '%T@\n' | sort -n | tail -1 | cut -f1- -d" ")
PREV=$(cat "$BPATH/timestamp_$NAME.txt")
echo $LAST>"$BPATH/timestamp_$NAME.txt"
if [ "$LAST" != "$PREV" ]
then
/usr/syno/bin/synosnapschedtask.sh local share "$NAME"
else
echo Nothing to do | tee -a $RUNLOG
fi
echo ------------------- END SNAPSHOT $NAME -- $(date) | tee -a $RUNLOG
NAME="Kirby"
echo ------------------- START SNAPSHOT $NAME -- $(date) | tee -a $RUNLOG
SOURCE="/volume1/$NAME"
LAST=$(find $SOURCE -type d -name '#snapshot' -prune -o -type d -name 'log' -prune -o -type f -printf '%T@\n' | sort -n | tail -1 | cut -f1- -d" ")
PREV=$(cat "$BPATH/timestamp_$NAME.txt")
echo $LAST>"$BPATH/timestamp_$NAME.txt"
if [ "$LAST" != "$PREV" ]
then
/usr/syno/bin/synosnapschedtask.sh local share "$NAME"
else
echo Nothing to do | tee -a $RUNLOG
fi
echo ------------------- END SNAPSHOT $NAME -- $(date) | tee -a $RUNLOG
NAME="Tobi"
echo ------------------- START SNAPSHOT $NAME -- $(date) | tee -a $RUNLOG
SOURCE="/volume1/$NAME"
LAST=$(find $SOURCE -type d -name '#snapshot' -prune -o -type d -name 'log' -prune -o -type f -printf '%T@\n' | sort -n | tail -1 | cut -f1- -d" ")
PREV=$(cat "$BPATH/timestamp_$NAME.txt")
echo $LAST>"$BPATH/timestamp_$NAME.txt"
if [ "$LAST" != "$PREV" ]
then
/usr/syno/bin/synosnapschedtask.sh local share "$NAME"
else
echo Nothing to do | tee -a $RUNLOG
fi
echo ------------------- END SNAPSHOT $NAME -- $(date) | tee -a $RUNLOG
NAME="web"
echo ------------------- START SNAPSHOT $NAME -- $(date) | tee -a $RUNLOG
SOURCE="/volume1/$NAME"
LAST=$(find $SOURCE -type d -name '#snapshot' -prune -o -type d -name 'log' -prune -o -type f -printf '%T@\n' | sort -n | tail -1 | cut -f1- -d" ")
PREV=$(cat "$BPATH/timestamp_$NAME.txt")
echo $LAST>"$BPATH/timestamp_$NAME.txt"
if [ "$LAST" != "$PREV" ]
then
/usr/syno/bin/synosnapschedtask.sh local share "$NAME"
else
echo Nothing to do | tee -a $RUNLOG
fi
echo ------------------- END SNAPSHOT $NAME -- $(date) | tee -a $RUNLOG
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment