From: Tom Hughes Date: Mon, 8 Jul 2019 21:35:23 +0000 (+0100) Subject: Modify backup expiry script to expire everything when no prefix is given X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/aabbf4d8f3be25ce4e2253074a6c49ab7573ac03 Modify backup expiry script to expire everything when no prefix is given --- diff --git a/cookbooks/backup/files/default/expire-backups b/cookbooks/backup/files/default/expire-backups index 4e26e3711..0cd75a502 100644 --- a/cookbooks/backup/files/default/expire-backups +++ b/cookbooks/backup/files/default/expire-backups @@ -18,6 +18,15 @@ my $dir = shift; my $prefix = shift; my @dates; +if ($prefix) +{ + $prefix = "${prefix}-"; +} +else +{ + $prefix = "(?:.*-)?"; +} + for my $day (0 .. $days - 1) { push(@dates, sprintf("%04d-%02d-%02d", Subtract_Delta_Days(Today(), $day))); @@ -34,8 +43,8 @@ for my $month (0 .. $months - 1) } my $dates = join("|", @dates); -my $match = qr/^${prefix}-\d{4}-\d{2}-\d{2}\./; -my $keep = qr/^${prefix}-(?:${dates})\./; +my $match = qr/^${prefix}\d{4}-\d{2}-\d{2}\./; +my $keep = qr/^${prefix}(?:${dates})\./; opendir(DIR, "$dir") || die "Can't open ${dir}: $!";