fix(syncoid): regather $snaps on --delete-target-snapshots flag

This commit is contained in:
Adam Fulton 2024-04-01 11:53:45 -05:00
parent 19fc237476
commit f89372967f
1 changed files with 10 additions and 0 deletions

10
syncoid
View File

@ -865,6 +865,16 @@ sub syncdataset {
# those that exist on the source. Remaining are the snapshots # those that exist on the source. Remaining are the snapshots
# that are only on the target. Then sort to remove the oldest # that are only on the target. Then sort to remove the oldest
# snapshots first. # snapshots first.
# regather snapshots on source and target
%snaps = getsnaps('source',$sourcehost,$sourcefs,$sourceisroot);
if ($targetexists) {
my %targetsnaps = getsnaps('target',$targethost,$targetfs,$targetisroot);
my %sourcesnaps = %snaps;
%snaps = (%sourcesnaps, %targetsnaps);
}
my @to_delete = sort { sortsnapshots(\%snaps, $a, $b) } grep {!exists $snaps{'source'}{$_}} keys %{ $snaps{'target'} }; my @to_delete = sort { sortsnapshots(\%snaps, $a, $b) } grep {!exists $snaps{'source'}{$_}} keys %{ $snaps{'target'} };
while (@to_delete) { while (@to_delete) {
# Create batch of snapshots to remove # Create batch of snapshots to remove