Merge branch 'master' of eternae.ink:arisu/server-scripts

This commit is contained in:
Alice Gaudon 2021-01-08 15:04:46 +01:00
commit 1a4db3330e
1 changed files with 16 additions and 7 deletions

View File

@ -1,6 +1,5 @@
#!/bin/bash
PREFIX="zsc-"
CONFIG_FILE="$HOME/.zfs_snapshot_cron"
FORMAT='+%Y-%m-%d'
@ -16,7 +15,17 @@ handle_pool() {
W=$3
M=$4
Y=$5
echo "--- $POOL --- $D $W $M $Y"
PREFIX=$6
if test -z "$PREFIX"; then
PREFIX="zsc-"
fi
if test "!no_prefix!" = "$PREFIX"; then
PREFIX=""
fi
echo "--- $POOL --- $D $W $M $Y $PREFIX"
SNAPSHOTS=($(zfs list -t snapshot -o name | grep "$POOL@$PREFIX" | sort -r))
echo "Snapshots: ${#SNAPSHOTS[@]}"
@ -30,7 +39,7 @@ handle_pool() {
EXISTS=1
fi
scomp=($(split_date "$sdate") $(date -d "$sdate" "+%u %W"))
scomp=($(split_date "$sdate") $(date -d "$stripped_date" "+%u %W"))
echo -n "${scomp[3]} ${scomp[4]} | "
@ -60,20 +69,20 @@ handle_pool() {
fi
}
cat "$CONFIG_FILE" | while IFS=: read pool recursive d w m y; do
echo "| ##### Pool: $pool Recursive: $recursive d: $d w: $w m: $m y: $y #####"
cat "$CONFIG_FILE" | while IFS=: read pool recursive d w m y prefix; do
echo "| ##### Pool: $pool Recursive: $recursive Prefix: $prefix d: $d w: $w m: $m y: $y #####"
if [ $recursive = "true" ]; then
SUBPOOLS=($(zfs list -o name | grep "$pool/"))
echo -e "Subpools: ${SUBPOOLS[@]}"
echo -e '|'
for p in "${SUBPOOLS[@]}"; do
handle_pool $p $d $w $m $y | awk '{print "| " $0}'
handle_pool $p $d $w $m $y $prefix | awk '{print "| " $0}'
echo -e '|'
done
fi
handle_pool $pool $d $w $m $y | awk '{print "| " $0}'
handle_pool $pool $d $w $m $y $prefix | awk '{print "| " $0}'
echo -e "----------------------------------------------------------------------"
done