Fix snaps to delete

This commit is contained in:
Thorsten Spille 2023-03-04 21:52:18 +01:00
parent 1e2343f908
commit a817abbe2d

View File

@ -163,7 +163,7 @@ for name in "${syncvols[@]}"; do
guid=$($ssh $sshcipher $sshport $source "zfs list -H -o guid,name -S creation -t snapshot $name | grep $interval | cut -f1 | tail -1") guid=$($ssh $sshcipher $sshport $source "zfs list -H -o guid,name -S creation -t snapshot $name | grep $interval | cut -f1 | tail -1")
if [[ "$(echo -e "$guid" | sed 's/\n//g')" != "" ]]; then if [[ "$(echo -e "$guid" | sed 's/\n//g')" != "" ]]; then
snaps_to_delete=$($zfs list -H -o name,guid -S creation -t snapshot $target/$name | grep $interval | grep --after-context=200 $guid | grep -v $guid | cut -f1) snaps_to_delete=$($zfs list -H -o name,guid -S creation -t snapshot $target/$name | grep $interval | grep --after-context=200 $guid | grep -v $guid | cut -f1)
delete_count=$(echo $snaps_to_delete | wc -l) delete_count=$($zfs list -H -o name,guid -S creation -t snapshot $target/$name | grep $interval | wc -l)
for snap in $snaps_to_delete; do for snap in $snaps_to_delete; do
if [[ $delete_count -gt $min_keep ]]; then if [[ $delete_count -gt $min_keep ]]; then
log "Deleting $snap" log "Deleting $snap"