local/bin/btrfs-snap-all: Init.
parent
5739f9cb9d
commit
3261b72d7a
|
@ -0,0 +1,41 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
usage () {
|
||||||
|
cat <<EOF>&2
|
||||||
|
Usage: ${0##*/}
|
||||||
|
|
||||||
|
Snapshot all Btrfs subvolumes older than 1 day to a read-only '.snapshots/SUBVOLUME/DATE'.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -ne 0 ]; then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
while IFS= read -r fs; do
|
||||||
|
for subvol in private public; do
|
||||||
|
last=$(ls -1 .snapshots/"$subvol" | tail -1 | sed 's/_/ /')
|
||||||
|
if [ -z "$last" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
last_date=$(date --date="$last" +%s)
|
||||||
|
now=$(date +%s)
|
||||||
|
if [ $(($now - $last_date)) -gt 86400 ]; then
|
||||||
|
choice=N
|
||||||
|
echo -n "==> Snapshot '$fs/${subvol}'? (y/N) "
|
||||||
|
read -r choice
|
||||||
|
case "$choice" in
|
||||||
|
Y|y)
|
||||||
|
btrfs-snap "$fs/$subvol" ;;
|
||||||
|
esac
|
||||||
|
unset choice
|
||||||
|
fi
|
||||||
|
unset now
|
||||||
|
unset last_date
|
||||||
|
unset last
|
||||||
|
done
|
||||||
|
done <<EOF
|
||||||
|
$(findmnt -t btrfs -n --output TARGET)
|
||||||
|
EOF
|
Loading…
Reference in New Issue