From 8f1c026c78d10d399f99688fc71101246087b368 Mon Sep 17 00:00:00 2001 From: Someone Date: Fri, 18 Jan 2013 05:48:52 +0100 Subject: [PATCH] some changes, added timestamping, ... --- cleaner.sh | 16 ++++++++-------- snapshot.sh | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cleaner.sh b/cleaner.sh index f040eb2..2ee0ace 100755 --- a/cleaner.sh +++ b/cleaner.sh @@ -7,15 +7,14 @@ # This script will update current/last_day/week/month snapshots and will delete snapshots if needed (too many or low on space) # #set volumes to do curr/last day/month for. -LASTLIST="root home rw" +LASTLIST="root home homeroot var" - -#TODO: change autoclean behaviour from auto_* to *.snap # Autosnaps to keep. Counting/Considering *.snap only. There should be adate_*.snap snapshots only. -let MINSNAPCNT=3*5 -let MAXSNAPCNT=3*300 -MAXSPACEPERCENT=85 +let MINSNAPCNT=4*5 +let MAXSNAPCNT=4*200 +MAXSPACEPERCENT=90 +echo "***START: `date`***" if [ -e /tmp/btrfs_cleaner.lock ]; then echo "Lockfile found. Assuming another instance is running. exitting." exit 1 @@ -77,14 +76,14 @@ while [ $LOOPDEL -eq 2 ]; do SPACEALLOC="`grep 'size' /tmp/btrfs_fishow.txt | sed -E 's~^.*?GB used ([0-9]+\.[0-9]*)GB.*?$~\1~g'`" rm /tmp/btrfs_fishow.txt - SNAPCNT="`find . -maxdepth 1 -name 'auto_*' -o -name '*.snap' | wc -l`" + SNAPCNT="`find . -maxdepth 1 -name '*.snap' | wc -l`" SPACEPERCENT="`python -c 'print int(100.0*'${SPACEUSED}'/'${SPACESIZE}')'`" echo "Autosnap cleaner: Snap count min/curr/limit [${MINSNAPCNT}/${SNAPCNT}/${MAXSNAPCNT}]." echo "Autosnap cleaner: Space used/alloc/size/limit [${SPACEUSED}/${SPACEALLOC}/${SPACESIZE}][${SPACEPERCENT}%/${MAXSPACEPERCENT}%]" if [ $SNAPCNT -gt $MAXSNAPCNT -o $SPACEPERCENT -gt $MAXSPACEPERCENT ]; then - DELFILE="`find . -maxdepth 1 -name 'auto_*' | sort | head -n -${MINSNAPCNT} | head -n 1`" + DELFILE="`find . -maxdepth 1 -name '*.snap' | sort | head -n -${MINSNAPCNT} | head -n 1`" if [ $SNAPCNT -gt $MINSNAPCNT -a "$DELFILE" != "" ]; then btrfs subvolume delete "${DELFILE}" && LOOPDEL=2 fi @@ -96,4 +95,5 @@ done umount /mnt/btrfs &> /dev/null rm -rf /tmp/btrfs_cleaner.lock +echo "***END: `date`***" diff --git a/snapshot.sh b/snapshot.sh index d675e72..4d1439a 100755 --- a/snapshot.sh +++ b/snapshot.sh @@ -5,12 +5,13 @@ # This script will generate: current_$vol.snp/.txt + last_$vol.snp/.txt and date_$date_$vol.snp/.txt # # Set volumes to autosnap -SNAPLIST="root home rw" +SNAPLIST="root home var homeroot" # Timestamp of creation. STARTTS="`date +'%Y-%m-%d--%H-%M'`" CALLPATH="`pwd`" +echo $STARTTS mount /mnt/btrfs &> /dev/null cd /mnt/btrfs -- 2.43.0