Created
February 15, 2020 20:39
-
-
Save Egregius/3fc5afef60f91de7a141d9efc010fbc9 to your computer and use it in GitHub Desktop.
Synology btrfs snapshots when needed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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