X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/0ab00370e185911f8cac05ef1a6a15219ae960fe..a9a47cf9a73e9ec2454ec71a25acd64f9f6286f9:/cookbooks/backup/files/default/expire-backups diff --git a/cookbooks/backup/files/default/expire-backups b/cookbooks/backup/files/default/expire-backups index 0cd75a502..81834d437 100644 --- a/cookbooks/backup/files/default/expire-backups +++ b/cookbooks/backup/files/default/expire-backups @@ -48,14 +48,18 @@ my $keep = qr/^${prefix}(?:${dates})\./; opendir(DIR, "$dir") || die "Can't open ${dir}: $!"; -while (my $file = readdir(DIR)) -{ -# print "Expiring $file\n" if $file =~ $match && $file !~ $keep; - unlink("${dir}/${file}") if $file =~ $match && $file !~ $keep; -} +my @files = sort(grep($match, readdir(DIR))); closedir(DIR); +pop @files; + +for my $file (@files) +{ +# print "Expiring $file\n" if $file !~ $keep; + unlink("${dir}/${file}") if $file !~ $keep; +} + exit 0; sub Monday