|
|
@@ -42,16 +42,13 @@
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
- # Delete old roots older than 30 days
|
|
|
- for i in $(btrfs subvolume list /mnt | grep 'old-roots/@root-' | cut -f 9- -d ' '); do
|
|
|
- subvol_time=$(echo "$i" | grep -o '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}_[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}')
|
|
|
- if [[ -n "$subvol_time" ]]; then
|
|
|
- subvol_secs=$(date -d "$subvol_time" +%s 2>/dev/null || continue)
|
|
|
- thirty_days_ago=$(date -d "30 days ago" +%s)
|
|
|
- if [[ $subvol_secs -lt $thirty_days_ago ]]; then
|
|
|
- delete_subvolume_recursively "/mnt/$i"
|
|
|
- fi
|
|
|
+ # Delete old roots more than 5
|
|
|
+ index=0
|
|
|
+ for i in $(btrfs subvolume list /mnt | grep 'old-roots/@root-' | cut -f 9- -d ' ' | sort -r); do
|
|
|
+ if [[ $index -ge 5 ]]; then
|
|
|
+ delete_subvolume_recursively "/mnt/$i"
|
|
|
fi
|
|
|
+ index=$((index + 1))
|
|
|
done
|
|
|
|
|
|
# Create or restore fresh root
|