]> git.openstreetmap.org Git - chef.git/commitdiff
Fix backup expiry script to match prefixes correctly
authorTom Hughes <tom@compton.nu>
Tue, 6 Sep 2022 21:45:40 +0000 (22:45 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 6 Sep 2022 21:46:05 +0000 (22:46 +0100)
cookbooks/backup/files/default/expire-backups

index 81834d43711197c1a129044b68b25f379d98ef96..9d82c384a620c656115fd75d2c749a62e265c1e7 100644 (file)
@@ -43,12 +43,12 @@ for my $month (0 .. $months - 1)
 }
 
 my $dates = join("|", @dates);
 }
 
 my $dates = join("|", @dates);
-my $match = qr/^${prefix}\d{4}-\d{2}-\d{2}\./;
-my $keep = qr/^${prefix}(?:${dates})\./;
+my $match = qr/^\Q${prefix}\E\d{4}-\d{2}-\d{2}\./;
+my $keep = qr/^\Q${prefix}\E(?:${dates})\./;
 
 opendir(DIR, "$dir") || die "Can't open ${dir}: $!";
 
 
 opendir(DIR, "$dir") || die "Can't open ${dir}: $!";
 
-my @files = sort(grep($match, readdir(DIR)));
+my @files = sort(grep(/$match/, readdir(DIR)));
 
 closedir(DIR);
 
 
 closedir(DIR);