local/bin/homesync: Snapshot subvolumes.

master
Pierre Neidhardt 2019-09-19 13:28:04 +02:00
parent 46a2f9d950
commit b65c93751d
1 changed files with 21 additions and 0 deletions

View File

@ -58,6 +58,27 @@ message() {
echo -e "$YELLOW:: $@$NORMAL"
}
section Snapshot subvolumes if older then 1 day
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
message "Snapshot $fs/$subvol"
btrfs-snap "$fs/$subvol"
fi
unset now
unset last_date
unset last
done
done <<EOF
$(findmnt -t btrfs -n --output TARGET)
EOF
if [ -n "$OPT_DATAROOT" ]; then
section Data index
for i in "$OPT_DATAROOT"/*; do