Make use of rolling_datasets on omen

Signed-off-by: magic_rb <richard@brezak.sk>
This commit is contained in:
magic_rb 2023-10-07 22:43:51 +02:00
parent 52a6d7d312
commit f59ae5dc71
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E

View file

@ -81,22 +81,7 @@
unitConfig.DefaultDependencies = "no";
serviceConfig.Type = "oneshot";
script = ''
generation="$(zfs get :generation omen-ssd/ephemeral/home -H -o value)"
dataset="omen-ssd/ephemeral/home"
generation="$(("$generation" + 1))"
zfs set ":generation=$generation" "$dataset"
zfs send "$dataset" | zfs recv "$dataset/$generation"
zfs rollback "$dataset@blank" && echo "rollback complete"
while IFS="\n" read gen
do
echo "$gen < $(("$generation" - 10))"
if [ "$gen" -lt "$(("$generation" - 10))" ]; then
zfs destroy -r "$dataset/$gen"
echo "destroyed "
fi
done <<< "$(zfs list "omen-ssd/ephemeral/home" -t filesystem -r -H -o name | xargs -I {} ${pkgs.runtimeShell} -c 'echo "$1" | rev | cut -f 1 -d "/" | rev' sh {} | grep -v home)"
${pkgs.rolling_datasets}/bin/roll_dataset "omen-ssd/ephemeral/home" "10"
'';
};