mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
148836fe44
* Includes updating the manifest to format 4. It turns out the manifest and .info files were not very good for providing information. A format update was required anyway so worked through the backlog of changes that would require a format change. * Multiple database versions are now supported in the archive. Does't actually work yet but the structure should be good. * Tests use more constants now that test logs can catch name regressions.
81 lines
2.0 KiB
Perl
81 lines
2.0 KiB
Perl
####################################################################################################################################
|
|
# BACKUP COMMON MODULE
|
|
####################################################################################################################################
|
|
package BackRest::BackupCommon;
|
|
|
|
use strict;
|
|
use warnings FATAL => qw(all);
|
|
use Carp qw(confess);
|
|
|
|
use Exporter qw(import);
|
|
use File::Basename;
|
|
|
|
use lib dirname($0);
|
|
use BackRest::Utility;
|
|
|
|
####################################################################################################################################
|
|
# backupRegExpGet - Generate a regexp depending on the backups that need to be found
|
|
####################################################################################################################################
|
|
our @EXPORT = qw(backupRegExpGet);
|
|
|
|
sub backupRegExpGet
|
|
{
|
|
my $bFull = shift;
|
|
my $bDifferential = shift;
|
|
my $bIncremental = shift;
|
|
|
|
if (!$bFull && !$bDifferential && !$bIncremental)
|
|
{
|
|
confess &log(ERROR, 'one parameter must be true');
|
|
}
|
|
|
|
my $strDateTimeRegExp = "[0-9]{8}\\-[0-9]{6}";
|
|
my $strRegExp = '^';
|
|
|
|
if ($bFull || $bDifferential || $bIncremental)
|
|
{
|
|
$strRegExp .= $strDateTimeRegExp . 'F';
|
|
}
|
|
|
|
if ($bDifferential || $bIncremental)
|
|
{
|
|
if ($bFull)
|
|
{
|
|
$strRegExp .= "(\\_";
|
|
}
|
|
else
|
|
{
|
|
$strRegExp .= "\\_";
|
|
}
|
|
|
|
$strRegExp .= $strDateTimeRegExp;
|
|
|
|
if ($bDifferential && $bIncremental)
|
|
{
|
|
$strRegExp .= '(D|I)';
|
|
}
|
|
elsif ($bDifferential)
|
|
{
|
|
$strRegExp .= 'D';
|
|
}
|
|
else
|
|
{
|
|
$strRegExp .= 'I';
|
|
}
|
|
|
|
if ($bFull)
|
|
{
|
|
$strRegExp .= '){0,1}';
|
|
}
|
|
}
|
|
|
|
$strRegExp .= "\$";
|
|
|
|
&log(DEBUG, "BackupCommon::backupRegExpGet:" .
|
|
" full = ${bFull}, differential = ${bDifferential}, incremental = ${bIncremental}: $strRegExp");
|
|
|
|
return $strRegExp;
|
|
}
|
|
|
|
1;
|