2015-08-29 20:20:46 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# EXPIRE MODULE
|
|
|
|
####################################################################################################################################
|
2016-04-14 15:30:54 +02:00
|
|
|
package pgBackRest::Expire;
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use Exporter qw(import);
|
|
|
|
use File::Basename qw(dirname);
|
|
|
|
use File::Path qw(remove_tree);
|
|
|
|
use Scalar::Util qw(looks_like_number);
|
|
|
|
|
|
|
|
use lib dirname($0);
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRest::Common::Exception;
|
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
use pgBackRest::BackupCommon;
|
|
|
|
use pgBackRest::BackupInfo;
|
|
|
|
use pgBackRest::Config::Config;
|
|
|
|
use pgBackRest::File;
|
|
|
|
use pgBackRest::FileCommon;
|
|
|
|
use pgBackRest::Manifest;
|
2016-08-24 18:39:27 +02:00
|
|
|
use pgBackRest::Protocol::Common;
|
|
|
|
use pgBackRest::Protocol::Protocol;
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# new
|
|
|
|
####################################################################################################################################
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $class = shift;
|
|
|
|
|
|
|
|
# Create the class hash
|
|
|
|
my $self = {};
|
|
|
|
bless $self, $class;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
2016-08-11 23:32:28 +02:00
|
|
|
my ($strOperation) = logDebugParam(__PACKAGE__ . '->new');
|
2015-10-08 17:43:56 +02:00
|
|
|
|
|
|
|
# Initialize file object
|
2016-04-14 15:30:54 +02:00
|
|
|
$self->{oFile} = new pgBackRest::File
|
2015-08-29 20:20:46 +02:00
|
|
|
(
|
2015-10-08 17:43:56 +02:00
|
|
|
optionGet(OPTION_STANZA),
|
2016-04-14 15:30:54 +02:00
|
|
|
optionGet(OPTION_REPO_PATH),
|
2016-08-24 18:39:27 +02:00
|
|
|
protocolGet(NONE)
|
2015-10-08 17:43:56 +02:00
|
|
|
);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
# Initialize total archive expired
|
|
|
|
$self->{iArchiveExpireTotal} = 0;
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'self', value => $self}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# DESTROY
|
|
|
|
####################################################################################################################################
|
|
|
|
sub DESTROY
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
2016-08-11 23:32:28 +02:00
|
|
|
my ($strOperation) = logDebugParam(__PACKAGE__ . '->DESTROY');
|
2015-10-08 17:43:56 +02:00
|
|
|
|
|
|
|
undef($self->{oFile});
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
2016-08-11 23:32:28 +02:00
|
|
|
return logDebugReturn($strOperation);
|
2015-10-08 17:43:56 +02:00
|
|
|
}
|
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# logExpire
|
|
|
|
#
|
|
|
|
# Tracks which archive logs have been removed and provides log messages when needed.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub logExpire
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
my $strArchiveFile = shift;
|
|
|
|
|
|
|
|
if (defined($strArchiveFile))
|
|
|
|
{
|
|
|
|
if (!defined($self->{strArchiveExpireStart}))
|
|
|
|
{
|
|
|
|
$self->{strArchiveExpireStart} = $strArchiveFile;
|
|
|
|
$self->{strArchiveExpireStop} = $strArchiveFile;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$self->{strArchiveExpireStop} = $strArchiveFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
$self->{iArchiveExpireTotal}++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (defined($self->{strArchiveExpireStart}))
|
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
&log(DETAIL, 'remove archive: start = ' . substr($self->{strArchiveExpireStart}, 0, 24) .
|
2016-01-21 00:24:44 +02:00
|
|
|
', stop = ' . substr($self->{strArchiveExpireStop}, 0, 24));
|
|
|
|
}
|
|
|
|
|
|
|
|
undef($self->{strArchiveExpireStart});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# process
|
|
|
|
#
|
|
|
|
# Removes expired backups and archive logs from the backup directory. Partial backups are not counted for expiration, so if full
|
|
|
|
# or differential retention is set to 2, there must be three complete backups before the oldest one can be deleted.
|
|
|
|
####################################################################################################################################
|
|
|
|
sub process
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
2016-08-11 23:32:28 +02:00
|
|
|
my ($strOperation) = logDebugParam(__PACKAGE__ . '->process');
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
my @stryPath;
|
|
|
|
|
|
|
|
my $oFile = $self->{oFile};
|
|
|
|
my $strBackupClusterPath = $oFile->pathGet(PATH_BACKUP_CLUSTER);
|
|
|
|
my $iFullRetention = optionGet(OPTION_RETENTION_FULL, false);
|
|
|
|
my $iDifferentialRetention = optionGet(OPTION_RETENTION_DIFF, false);
|
|
|
|
my $strArchiveRetentionType = optionGet(OPTION_RETENTION_ARCHIVE_TYPE, false);
|
|
|
|
my $iArchiveRetention = optionGet(OPTION_RETENTION_ARCHIVE, false);
|
|
|
|
|
|
|
|
# Load or build backup.info
|
2016-04-14 15:30:54 +02:00
|
|
|
my $oBackupInfo = new pgBackRest::BackupInfo($oFile->pathGet(PATH_BACKUP_CLUSTER));
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# Find all the expired full backups
|
|
|
|
if (defined($iFullRetention))
|
|
|
|
{
|
|
|
|
# Make sure iFullRetention is valid
|
|
|
|
if (!looks_like_number($iFullRetention) || $iFullRetention < 1)
|
|
|
|
{
|
2015-11-22 21:02:14 +02:00
|
|
|
confess &log(ERROR, 'retention-full must be a number >= 1');
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
|
2016-01-19 14:39:29 +02:00
|
|
|
@stryPath = $oBackupInfo->list(backupRegExpGet(true));
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2015-11-22 21:02:14 +02:00
|
|
|
if (@stryPath > $iFullRetention)
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2016-01-19 14:39:29 +02:00
|
|
|
# Expire all backups that depend on the full backup
|
2015-11-22 21:02:14 +02:00
|
|
|
for (my $iFullIdx = 0; $iFullIdx < @stryPath - $iFullRetention; $iFullIdx++)
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2015-11-22 21:02:14 +02:00
|
|
|
my @stryRemoveList;
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-02-23 16:25:22 +02:00
|
|
|
foreach my $strPath ($oBackupInfo->list('^' . $stryPath[$iFullIdx] . '.*'))
|
2015-11-22 21:02:14 +02:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
$oFile->remove(PATH_BACKUP_CLUSTER, "${strPath}/" . FILE_MANIFEST);
|
2015-11-22 21:02:14 +02:00
|
|
|
$oBackupInfo->delete($strPath);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2015-11-22 21:02:14 +02:00
|
|
|
if ($strPath ne $stryPath[$iFullIdx])
|
|
|
|
{
|
|
|
|
push(@stryRemoveList, $strPath);
|
|
|
|
}
|
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-01-19 14:39:29 +02:00
|
|
|
&log(INFO, 'expire full backup ' . (@stryRemoveList > 0 ? 'set: ' : '') . $stryPath[$iFullIdx] .
|
2015-11-22 21:02:14 +02:00
|
|
|
(@stryRemoveList > 0 ? ', ' . join(', ', @stryRemoveList) : ''));
|
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Find all the expired differential backups
|
|
|
|
if (defined($iDifferentialRetention))
|
|
|
|
{
|
|
|
|
# Make sure iDifferentialRetention is valid
|
|
|
|
if (!looks_like_number($iDifferentialRetention) || $iDifferentialRetention < 1)
|
|
|
|
{
|
2015-11-22 21:02:14 +02:00
|
|
|
confess &log(ERROR, 'retention-diff must be a number >= 1');
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
|
2016-09-07 14:07:37 +02:00
|
|
|
# Get a list of full and differential backups. Full are considered differential for the purpose of retention.
|
|
|
|
# Example: F1, D1, D2, F2 and retention-diff=2, then F1,D2,F2 will be retained, not D2 and D1 as might be expected.
|
|
|
|
@stryPath = $oBackupInfo->list(backupRegExpGet(true, true));
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2015-11-22 21:02:14 +02:00
|
|
|
if (@stryPath > $iDifferentialRetention)
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2015-11-22 21:02:14 +02:00
|
|
|
for (my $iDiffIdx = 0; $iDiffIdx < @stryPath - $iDifferentialRetention; $iDiffIdx++)
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2016-09-07 14:07:37 +02:00
|
|
|
# Skip if this is a full backup. Full backups only count as differential when deciding which differential backups
|
|
|
|
# to expire.
|
|
|
|
next if ($stryPath[$iDiffIdx] =~ backupRegExpGet(true));
|
|
|
|
|
2015-11-22 21:02:14 +02:00
|
|
|
# Get a list of all differential and incremental backups
|
|
|
|
my @stryRemoveList;
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-02-23 16:25:22 +02:00
|
|
|
foreach my $strPath ($oBackupInfo->list(backupRegExpGet(false, true, true)))
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2015-11-22 21:02:14 +02:00
|
|
|
logDebugMisc($strOperation, "checking ${strPath} for differential expiration");
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2015-11-22 21:02:14 +02:00
|
|
|
# Remove all differential and incremental backups before the oldest valid differential
|
|
|
|
if ($strPath lt $stryPath[$iDiffIdx + 1])
|
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
$oFile->remove(PATH_BACKUP_CLUSTER, "/${strPath}" . FILE_MANIFEST);
|
2015-11-22 21:02:14 +02:00
|
|
|
$oBackupInfo->delete($strPath);
|
|
|
|
|
|
|
|
if ($strPath ne $stryPath[$iDiffIdx])
|
|
|
|
{
|
|
|
|
push(@stryRemoveList, $strPath);
|
|
|
|
}
|
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
2015-11-22 21:02:14 +02:00
|
|
|
|
2016-01-19 14:39:29 +02:00
|
|
|
&log(INFO, 'expire diff backup ' . (@stryRemoveList > 0 ? 'set: ' : '') . $stryPath[$iDiffIdx] .
|
2015-11-22 21:02:14 +02:00
|
|
|
(@stryRemoveList > 0 ? ', ' . join(', ', @stryRemoveList) : ''));
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-19 14:39:29 +02:00
|
|
|
$oBackupInfo->save();
|
|
|
|
|
|
|
|
# Remove backups from disk
|
|
|
|
foreach my $strBackup ($oFile->list(PATH_BACKUP_CLUSTER, undef, backupRegExpGet(true, true, true), 'reverse'))
|
|
|
|
{
|
|
|
|
if (!$oBackupInfo->current($strBackup))
|
|
|
|
{
|
|
|
|
&log(INFO, "remove expired backup ${strBackup}");
|
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
remove_tree("${strBackupClusterPath}/${strBackup}") > 0
|
|
|
|
or confess &log(ERROR, "unable to remove backup ${strBackup}", ERROR_PATH_REMOVE);
|
2016-01-19 14:39:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-07 14:07:37 +02:00
|
|
|
# If archive retention is still undefined, then ignore archiving
|
|
|
|
if (!defined($iArchiveRetention))
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2016-09-07 14:07:37 +02:00
|
|
|
&log(INFO, "option '" . &OPTION_RETENTION_ARCHIVE . "' is not set - archive logs will not be expired");
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-09-07 14:07:37 +02:00
|
|
|
# Determine which backup type to use for archive retention (full, differential, incremental) and get a list of the
|
|
|
|
# remaining non-expired backups based on the type.
|
2015-08-29 20:20:46 +02:00
|
|
|
if ($strArchiveRetentionType eq BACKUP_TYPE_FULL)
|
|
|
|
{
|
2016-01-21 00:24:44 +02:00
|
|
|
@stryPath = $oBackupInfo->list(backupRegExpGet(true), 'reverse');
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
elsif ($strArchiveRetentionType eq BACKUP_TYPE_DIFF)
|
|
|
|
{
|
2016-01-21 00:24:44 +02:00
|
|
|
@stryPath = $oBackupInfo->list(backupRegExpGet(true, true), 'reverse');
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
elsif ($strArchiveRetentionType eq BACKUP_TYPE_INCR)
|
|
|
|
{
|
2016-01-21 00:24:44 +02:00
|
|
|
@stryPath = $oBackupInfo->list(backupRegExpGet(true, true, true), 'reverse');
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
|
2016-09-07 14:07:37 +02:00
|
|
|
# If no backups were found then preserve current archive logs - too soon to expire them
|
2015-08-29 20:20:46 +02:00
|
|
|
my $iBackupTotal = scalar @stryPath;
|
|
|
|
|
|
|
|
if ($iBackupTotal > 0)
|
|
|
|
{
|
|
|
|
# See if enough backups exist for expiration to start
|
|
|
|
my $strArchiveRetentionBackup = $stryPath[$iArchiveRetention - 1];
|
|
|
|
|
|
|
|
if (!defined($strArchiveRetentionBackup))
|
|
|
|
{
|
|
|
|
if ($strArchiveRetentionType eq BACKUP_TYPE_FULL && scalar @stryPath > 0)
|
|
|
|
{
|
2015-11-22 21:02:14 +02:00
|
|
|
&log(INFO, "full backup total < ${iArchiveRetention} - using oldest full backup for archive retention");
|
2015-08-29 20:20:46 +02:00
|
|
|
$strArchiveRetentionBackup = $stryPath[scalar @stryPath - 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
# If a backup has been selected for retention then continue
|
2015-08-29 20:20:46 +02:00
|
|
|
if (defined($strArchiveRetentionBackup))
|
|
|
|
{
|
2016-01-21 00:24:44 +02:00
|
|
|
my $bRemove;
|
2015-09-02 01:05:10 +02:00
|
|
|
|
2016-02-20 02:32:02 +02:00
|
|
|
# Only expire if the selected backup has archive info - backups performed with --no-online will
|
2016-01-21 00:24:44 +02:00
|
|
|
# not have archive info and cannot be used for expiration.
|
|
|
|
if ($oBackupInfo->test(INFO_BACKUP_SECTION_BACKUP_CURRENT,
|
|
|
|
$strArchiveRetentionBackup, INFO_BACKUP_KEY_ARCHIVE_START))
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2016-01-16 06:37:17 +02:00
|
|
|
# Get archive info
|
2016-04-14 15:30:54 +02:00
|
|
|
my $oArchive = new pgBackRest::Archive();
|
2016-07-29 20:02:11 +02:00
|
|
|
my $strArchiveId = $oArchive->getArchiveId($oFile);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
my $strArchiveExpireMax;
|
|
|
|
|
2016-09-07 14:07:37 +02:00
|
|
|
# Get archive ranges to preserve. Because archive retention can be less than total retention it is important
|
|
|
|
# to preserve archive that is required to make the older backups consistent even though they cannot be played
|
|
|
|
# any further forward with PITR.
|
2016-01-21 00:24:44 +02:00
|
|
|
my @oyArchiveRange;
|
|
|
|
|
|
|
|
foreach my $strBackup ($oBackupInfo->list())
|
|
|
|
{
|
|
|
|
if ($strBackup le $strArchiveRetentionBackup &&
|
|
|
|
$oBackupInfo->test(INFO_BACKUP_SECTION_BACKUP_CURRENT, $strBackup, INFO_BACKUP_KEY_ARCHIVE_START))
|
|
|
|
{
|
|
|
|
my $oArchiveRange = {};
|
|
|
|
|
|
|
|
$$oArchiveRange{start} = $oBackupInfo->get(INFO_BACKUP_SECTION_BACKUP_CURRENT,
|
|
|
|
$strBackup, INFO_BACKUP_KEY_ARCHIVE_START);
|
|
|
|
|
|
|
|
if ($strBackup ne $strArchiveRetentionBackup)
|
|
|
|
{
|
|
|
|
$$oArchiveRange{stop} = $oBackupInfo->get(INFO_BACKUP_SECTION_BACKUP_CURRENT,
|
|
|
|
$strBackup, INFO_BACKUP_KEY_ARCHIVE_STOP);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$strArchiveExpireMax = $$oArchiveRange{start};
|
|
|
|
}
|
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
&log(DETAIL, "archive retention on backup ${strBackup}, start = $$oArchiveRange{start}" .
|
2016-01-21 00:24:44 +02:00
|
|
|
(defined($$oArchiveRange{stop}) ? ", stop = $$oArchiveRange{stop}" : ''));
|
|
|
|
|
|
|
|
push(@oyArchiveRange, $oArchiveRange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get all major archive paths (timeline and first 64 bits of LSN)
|
2016-02-23 16:25:22 +02:00
|
|
|
foreach my $strPath ($oFile->list(PATH_BACKUP_ARCHIVE, $strArchiveId, "^[0-F]{16}\$"))
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2016-01-16 06:37:17 +02:00
|
|
|
logDebugMisc($strOperation, "found major WAL path: ${strPath}");
|
2016-01-21 00:24:44 +02:00
|
|
|
$bRemove = true;
|
|
|
|
|
|
|
|
# Keep the path if it falls in the range of any backup in retention
|
|
|
|
foreach my $oArchiveRange (@oyArchiveRange)
|
|
|
|
{
|
|
|
|
if ($strPath ge substr($$oArchiveRange{start}, 0, 16) &&
|
|
|
|
(!defined($$oArchiveRange{stop}) || $strPath le substr($$oArchiveRange{stop}, 0, 16)))
|
|
|
|
{
|
|
|
|
$bRemove = false;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
# Remove the entire directory if all archive is expired
|
|
|
|
if ($bRemove)
|
2016-01-16 06:37:17 +02:00
|
|
|
{
|
|
|
|
my $strFullPath = $oFile->pathGet(PATH_BACKUP_ARCHIVE, $strArchiveId) . "/${strPath}";
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
remove_tree($strFullPath) > 0
|
|
|
|
or confess &log(ERROR, "unable to remove ${strFullPath}", ERROR_PATH_REMOVE);
|
2015-09-02 01:05:10 +02:00
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
# Log expire info
|
2016-01-16 06:37:17 +02:00
|
|
|
logDebugMisc($strOperation, "remove major WAL path: ${strFullPath}");
|
2016-01-21 00:24:44 +02:00
|
|
|
$self->logExpire($strPath);
|
2016-01-16 06:37:17 +02:00
|
|
|
}
|
2016-01-21 00:24:44 +02:00
|
|
|
# Else delete individual files instead if the major path is less than or equal to the most recent retention
|
|
|
|
# backup. This optimization prevents scanning though major paths that could not possibly have anything to
|
|
|
|
# expire.
|
|
|
|
elsif ($strPath le substr($strArchiveExpireMax, 0, 16))
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2016-01-21 00:24:44 +02:00
|
|
|
# Look for files in the archive directory
|
|
|
|
foreach my $strSubPath ($oFile->list(PATH_BACKUP_ARCHIVE,
|
|
|
|
"${strArchiveId}/${strPath}", "^[0-F]{24}.*\$"))
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2016-01-21 00:24:44 +02:00
|
|
|
$bRemove = true;
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
# Determine if the individual archive log is used in a backup
|
|
|
|
foreach my $oArchiveRange (@oyArchiveRange)
|
|
|
|
{
|
|
|
|
if (substr($strSubPath, 0, 24) ge $$oArchiveRange{start} &&
|
|
|
|
(!defined($$oArchiveRange{stop}) || substr($strSubPath, 0, 24) le $$oArchiveRange{stop}))
|
2016-01-16 06:37:17 +02:00
|
|
|
{
|
2016-01-21 00:24:44 +02:00
|
|
|
$bRemove = false;
|
|
|
|
last;
|
2016-01-16 06:37:17 +02:00
|
|
|
}
|
2016-01-21 00:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Remove archive log if it is not used in a backup
|
|
|
|
if ($bRemove)
|
|
|
|
{
|
2016-04-14 01:09:35 +02:00
|
|
|
fileRemove($oFile->pathGet(PATH_BACKUP_ARCHIVE, "${strArchiveId}/${strSubPath}"));
|
2016-01-21 00:24:44 +02:00
|
|
|
|
|
|
|
logDebugMisc($strOperation, "remove WAL segment: ${strSubPath}");
|
2015-09-02 01:05:10 +02:00
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
# Log expire info
|
|
|
|
$self->logExpire(substr($strSubPath, 0, 24));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# Log that the file was not expired
|
|
|
|
$self->logExpire();
|
2016-01-16 06:37:17 +02:00
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-02 01:05:10 +02:00
|
|
|
|
2016-01-21 00:24:44 +02:00
|
|
|
# Log if no archive was expired
|
|
|
|
if ($self->{iArchiveExpireTotal} == 0)
|
2016-01-16 06:37:17 +02:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
&log(DETAIL, 'no archive to remove');
|
2016-01-16 06:37:17 +02:00
|
|
|
}
|
2015-09-02 01:05:10 +02:00
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
2016-08-11 23:32:28 +02:00
|
|
|
return logDebugReturn($strOperation);
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|