2014-03-06 03:53:13 +03:00
|
|
|
####################################################################################################################################
|
|
|
|
# BACKUP MODULE
|
|
|
|
####################################################################################################################################
|
2016-04-14 15:30:54 +02:00
|
|
|
package pgBackRest::Backup;
|
2014-03-06 03:53:13 +03:00
|
|
|
|
|
|
|
use threads;
|
|
|
|
use strict;
|
2015-03-03 07:57:20 +02:00
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
2014-07-28 01:13:23 +03:00
|
|
|
|
2015-06-14 00:25:49 +02:00
|
|
|
use Exporter qw(import);
|
|
|
|
use Fcntl 'SEEK_CUR';
|
2014-03-06 03:53:13 +03:00
|
|
|
use File::Basename;
|
|
|
|
use File::Path qw(remove_tree);
|
|
|
|
use Thread::Queue;
|
|
|
|
|
|
|
|
use lib dirname($0);
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRest::Common::Exception;
|
|
|
|
use pgBackRest::Common::Exit;
|
|
|
|
use pgBackRest::Common::Ini;
|
|
|
|
use pgBackRest::Common::Log;
|
2016-04-15 04:50:02 +02:00
|
|
|
use pgBackRest::Common::Wait;
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRest::Archive;
|
|
|
|
use pgBackRest::BackupCommon;
|
|
|
|
use pgBackRest::BackupFile;
|
|
|
|
use pgBackRest::BackupInfo;
|
|
|
|
use pgBackRest::Common::String;
|
|
|
|
use pgBackRest::Config::Config;
|
|
|
|
use pgBackRest::Db;
|
|
|
|
use pgBackRest::File;
|
|
|
|
use pgBackRest::FileCommon;
|
|
|
|
use pgBackRest::Manifest;
|
|
|
|
use pgBackRest::Version;
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# Operation constants
|
|
|
|
####################################################################################################################################
|
|
|
|
use constant OP_BACKUP => 'Backup';
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
use constant OP_BACKUP_DESTROY => OP_BACKUP . '->DESTROY';
|
|
|
|
use constant OP_BACKUP_FILE_NOT_IN_MANIFEST => OP_BACKUP . '->fileNotInManifest';
|
|
|
|
use constant OP_BACKUP_NEW => OP_BACKUP . '->new';
|
|
|
|
use constant OP_BACKUP_PROCESS => OP_BACKUP . '->process';
|
|
|
|
use constant OP_BACKUP_PROCESS_MANIFEST => OP_BACKUP . '->processManifest';
|
|
|
|
use constant OP_BACKUP_TMP_CLEAN => OP_BACKUP . '->tmpClean';
|
2014-03-06 03:53:13 +03:00
|
|
|
|
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# new
|
2014-03-06 03:53:13 +03:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
sub new
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
my $class = shift; # Class name
|
|
|
|
|
|
|
|
# Create the class hash
|
|
|
|
my $self = {};
|
|
|
|
bless $self, $class;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
2015-10-08 17:43:56 +02:00
|
|
|
my ($strOperation) = logDebugParam(OP_BACKUP_NEW);
|
|
|
|
|
|
|
|
# Initialize default 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),
|
2015-10-08 17:43:56 +02:00
|
|
|
optionRemoteType(),
|
|
|
|
protocolGet()
|
|
|
|
);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
# Initialize variables
|
2016-04-14 15:30:54 +02:00
|
|
|
$self->{oDb} = new pgBackRest::Db();
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'self', value => $self}
|
|
|
|
);
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
|
2015-01-31 03:16:21 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# DESTROY
|
2015-01-31 03:16:21 +02:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
sub DESTROY
|
2015-01-31 03:16:21 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
|
|
|
OP_BACKUP_DESTROY
|
|
|
|
);
|
|
|
|
|
|
|
|
undef($self->{oFile});
|
|
|
|
undef($self->{oDb});
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation
|
|
|
|
);
|
2015-01-31 03:16:21 +02:00
|
|
|
}
|
|
|
|
|
2014-03-06 03:53:13 +03:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# fileNotInManifest
|
|
|
|
#
|
|
|
|
# Find all files in a backup path that are not in the supplied manifest.
|
2014-03-06 03:53:13 +03:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
sub fileNotInManifest
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
$strPathType,
|
|
|
|
$oManifest,
|
|
|
|
$oAbortedManifest
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
|
|
|
OP_BACKUP_FILE_NOT_IN_MANIFEST, \@_,
|
|
|
|
{name => 'strPathType', trace => true},
|
|
|
|
{name => 'oManifest', trace => true},
|
|
|
|
{name => 'oAbortedManifest', trace => true}
|
|
|
|
);
|
|
|
|
|
|
|
|
# Build manifest for aborted temp path
|
2014-09-14 22:31:56 +03:00
|
|
|
my %oFileHash;
|
2015-08-29 20:20:46 +02:00
|
|
|
$self->{oFile}->manifest($strPathType, undef, \%oFileHash);
|
|
|
|
|
|
|
|
# Get compress flag
|
|
|
|
my $bCompressed = $oAbortedManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_COMPRESS);
|
2014-09-14 22:31:56 +03:00
|
|
|
|
2014-03-06 03:53:13 +03:00
|
|
|
my @stryFile;
|
|
|
|
|
2015-06-21 18:06:13 +02:00
|
|
|
foreach my $strName (sort(keys(%{$oFileHash{name}})))
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
|
|
|
# Ignore certain files that will never be in the manifest
|
2015-06-14 00:25:49 +02:00
|
|
|
if ($strName eq FILE_MANIFEST ||
|
2014-09-16 15:55:40 +03:00
|
|
|
$strName eq '.')
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# Get the file type (all links will be deleted since they are easy to recreate)
|
|
|
|
my $cType = $oFileHash{name}{$strName}{type};
|
2015-06-14 00:25:49 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# If a directory check if it exists in the new manifest
|
|
|
|
if ($cType eq 'd')
|
|
|
|
{
|
|
|
|
if ($oManifest->test(MANIFEST_SECTION_TARGET_PATH, $strName))
|
2015-06-14 00:25:49 +02:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
next;
|
2015-06-14 00:25:49 +02:00
|
|
|
}
|
|
|
|
}
|
2016-04-15 04:50:02 +02:00
|
|
|
# Else if a file
|
|
|
|
elsif ($cType eq 'f')
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
# If the original backup was compressed the remove the extension before checking the manifest
|
|
|
|
my $strFile = $strName;
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
if ($bCompressed)
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
$strFile = substr($strFile, 0, length($strFile) - 3);
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# To be preserved the file must exist in the new manifest and not be a reference to a previous backup
|
|
|
|
if ($oManifest->test(MANIFEST_SECTION_TARGET_FILE, $strFile) &&
|
|
|
|
!$oManifest->test(MANIFEST_SECTION_TARGET_FILE, $strFile, MANIFEST_SUBKEY_REFERENCE))
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
# To be preserved the checksum must be defined
|
|
|
|
my $strChecksum = $oAbortedManifest->get(MANIFEST_SECTION_TARGET_FILE, $strFile, MANIFEST_SUBKEY_CHECKSUM, false);
|
|
|
|
|
|
|
|
# The timestamp should also match and the size if the file is not compressed. If the file is compressed it's
|
|
|
|
# not worth extracting the size - it will be hashed later to verify its authenticity.
|
|
|
|
if (defined($strChecksum) &&
|
|
|
|
($bCompressed || ($oManifest->numericGet(MANIFEST_SECTION_TARGET_FILE, $strFile, MANIFEST_SUBKEY_SIZE) ==
|
|
|
|
$oFileHash{name}{$strName}{size})) &&
|
|
|
|
$oManifest->numericGet(MANIFEST_SECTION_TARGET_FILE, $strFile, MANIFEST_SUBKEY_TIMESTAMP) ==
|
|
|
|
$oFileHash{name}{$strName}{modification_time})
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
$oManifest->set(MANIFEST_SECTION_TARGET_FILE, $strFile, MANIFEST_SUBKEY_CHECKSUM, $strChecksum);
|
2014-03-06 03:53:13 +03:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-23 03:07:49 +02:00
|
|
|
# Push the file/path/link to be deleted into the result array
|
2015-05-07 02:24:34 +02:00
|
|
|
push @stryFile, $strName;
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'stryFile', value => \@stryFile}
|
|
|
|
);
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# tmpClean
|
2014-06-04 18:58:30 +03:00
|
|
|
#
|
2014-03-06 03:53:13 +03:00
|
|
|
# Cleans the temp directory from a previous failed backup so it can be reused
|
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
sub tmpClean
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
$oManifest,
|
|
|
|
$oAbortedManifest
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
|
|
|
OP_BACKUP_TMP_CLEAN, \@_,
|
|
|
|
{name => 'oManifest', trace => true},
|
|
|
|
{name => 'oAbortedManifest', trace => true}
|
|
|
|
);
|
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
&log(DETAIL, 'clean backup temp path: ' . $self->{oFile}->pathGet(PATH_BACKUP_TMP));
|
2014-03-06 03:53:13 +03:00
|
|
|
|
|
|
|
# Get the list of files that should be deleted from temp
|
2015-08-29 20:20:46 +02:00
|
|
|
my @stryFile = $self->fileNotInManifest(PATH_BACKUP_TMP, $oManifest, $oAbortedManifest);
|
2014-03-06 03:53:13 +03:00
|
|
|
|
|
|
|
foreach my $strFile (sort {$b cmp $a} @stryFile)
|
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
my $strDelete = $self->{oFile}->pathGet(PATH_BACKUP_TMP, $strFile);
|
2014-06-04 18:58:30 +03:00
|
|
|
|
2014-03-06 03:53:13 +03:00
|
|
|
# If a path then delete it, all the files should have already been deleted since we are going in reverse order
|
|
|
|
if (-d $strDelete)
|
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
logDebugMisc($strOperation, "remove path ${strDelete}");
|
|
|
|
|
|
|
|
rmdir($strDelete)
|
|
|
|
or confess &log(ERROR, "unable to delete path ${strDelete}, is it empty?", ERROR_PATH_REMOVE);
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
# Else delete a file
|
|
|
|
else
|
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
logDebugMisc($strOperation, "remove file ${strDelete}");
|
2016-04-14 01:09:35 +02:00
|
|
|
fileRemove($strDelete);
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation
|
|
|
|
);
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# processManifest
|
2014-03-06 03:53:13 +03:00
|
|
|
#
|
2015-08-29 20:20:46 +02:00
|
|
|
# Process the file level backup. Uses the information in the manifest to determine which files need to be copied. Directories
|
|
|
|
# and tablespace links are only created when needed, except in the case of a full backup or if hardlinks are requested.
|
2014-03-06 03:53:13 +03:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
sub processManifest
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation,
|
2016-04-15 04:50:02 +02:00
|
|
|
$strDbPath,
|
2015-08-29 20:20:46 +02:00
|
|
|
$strType,
|
|
|
|
$bCompress,
|
|
|
|
$bHardLink,
|
|
|
|
$oBackupManifest # Manifest for the current backup
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
|
|
|
OP_BACKUP_PROCESS_MANIFEST, \@_,
|
2016-04-15 04:50:02 +02:00
|
|
|
{name => 'strDbPath'},
|
2015-08-29 20:20:46 +02:00
|
|
|
{name => 'strType'},
|
|
|
|
{name => 'bCompress'},
|
|
|
|
{name => 'bHardLink'},
|
|
|
|
{name => 'oBackupManifest'},
|
|
|
|
);
|
2014-03-06 03:53:13 +03:00
|
|
|
|
|
|
|
# Variables used for parallel copy
|
2015-04-07 13:34:37 +02:00
|
|
|
my %oFileCopyMap;
|
2014-03-06 03:53:13 +03:00
|
|
|
my $lFileTotal = 0;
|
2015-04-07 13:34:37 +02:00
|
|
|
my $lSizeTotal = 0;
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# If this is a full backup or hard-linked then create all paths
|
|
|
|
if ($bHardLink || $strType eq BACKUP_TYPE_FULL)
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
foreach my $strPath ($oBackupManifest->keys(MANIFEST_SECTION_TARGET_PATH))
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
if ($strPath ne '.')
|
2016-02-02 21:33:15 +02:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
$self->{oFile}->pathCreate(PATH_BACKUP_TMP, $strPath);
|
2016-02-02 21:33:15 +02:00
|
|
|
}
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
2016-04-15 04:50:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Iterate through the files for each backup source path
|
|
|
|
foreach my $strFile ($oBackupManifest->keys(MANIFEST_SECTION_TARGET_FILE))
|
|
|
|
{
|
|
|
|
# my $strBackupSourceFile = "${strBackupSourcePath}/${strFile}";
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# If the file has a reference it does not need to be copied since it can be retrieved from the referenced backup.
|
|
|
|
# However, if hard-linking is turned on the link will need to be created
|
|
|
|
my $bProcess = true;
|
|
|
|
my $strReference = $oBackupManifest->get(MANIFEST_SECTION_TARGET_FILE, $strFile, MANIFEST_SUBKEY_REFERENCE, false);
|
|
|
|
|
|
|
|
if (defined($strReference))
|
2015-05-07 02:24:34 +02:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
# If hardlinking is turned on then create a hardlink for files that have not changed since the last backup
|
|
|
|
if ($bHardLink)
|
|
|
|
{
|
|
|
|
logDebugMisc($strOperation, "hardlink ${strFile} to ${strReference}");
|
2015-05-07 02:24:34 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
$self->{oFile}->linkCreate(PATH_BACKUP_CLUSTER, "${strReference}/${strFile}",
|
|
|
|
PATH_BACKUP_TMP, "${strFile}", true, false, true);
|
|
|
|
}
|
|
|
|
else
|
2015-05-07 02:24:34 +02:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
logDebugMisc($strOperation, "reference ${strFile} to ${strReference}");
|
2015-05-07 02:24:34 +02:00
|
|
|
}
|
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
$bProcess = false;
|
2015-05-07 02:24:34 +02:00
|
|
|
}
|
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
if ($bProcess)
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
my $lFileSize = $oBackupManifest->numericGet(MANIFEST_SECTION_TARGET_FILE, $strFile, MANIFEST_SUBKEY_SIZE);
|
2014-06-04 18:58:30 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# Increment file total
|
|
|
|
$lFileTotal++;
|
2014-10-15 04:44:42 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
my $strFileKey;
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# By default put everything into a single queue
|
|
|
|
my $strQueueKey = MANIFEST_TARGET_PGDATA;
|
2015-05-07 02:24:34 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# If multiple threads and the file belongs in a tablespace then put in a tablespace-specific queue
|
|
|
|
if (optionGet(OPTION_THREAD_MAX) > 1 && index($strFile, DB_PATH_PGTBLSPC . '/') == 0)
|
|
|
|
{
|
|
|
|
$strQueueKey = DB_PATH_PGTBLSPC . '/' . (split('\/', $strFile))[1];
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
2014-10-15 04:44:42 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# Certain files are not copied until the end
|
|
|
|
if ($strFile eq MANIFEST_FILE_PGCONTROL)
|
2014-10-15 04:44:42 +03:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
$strFileKey = $strFile;
|
|
|
|
$oFileCopyMap{$strQueueKey}{$strFileKey}{skip} = true;
|
|
|
|
}
|
|
|
|
# Else continue normally
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$strFileKey = sprintf("%016d-${strFile}", $lFileSize);
|
|
|
|
$oFileCopyMap{$strQueueKey}{$strFileKey}{skip} = false;
|
2015-06-14 15:36:58 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# Add file size to total size
|
|
|
|
$lSizeTotal += $lFileSize;
|
2014-10-15 04:44:42 +03:00
|
|
|
}
|
2016-04-15 04:50:02 +02:00
|
|
|
|
|
|
|
$oFileCopyMap{$strQueueKey}{$strFileKey}{db_file} = $oBackupManifest->dbPathGet($strDbPath, $strFile);
|
|
|
|
$oFileCopyMap{$strQueueKey}{$strFileKey}{repo_file} = $strFile;
|
|
|
|
$oFileCopyMap{$strQueueKey}{$strFileKey}{size} = $lFileSize;
|
|
|
|
$oFileCopyMap{$strQueueKey}{$strFileKey}{modification_time} =
|
|
|
|
$oBackupManifest->numericGet(MANIFEST_SECTION_TARGET_FILE, $strFile, MANIFEST_SUBKEY_TIMESTAMP, false);
|
|
|
|
$oFileCopyMap{$strQueueKey}{$strFileKey}{checksum} =
|
|
|
|
$oBackupManifest->get(MANIFEST_SECTION_TARGET_FILE, $strFile, MANIFEST_SUBKEY_CHECKSUM, false);
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-15 03:42:11 +02:00
|
|
|
# pg_control should always be in the backup (unless this is an offline backup)
|
2016-04-15 04:50:02 +02:00
|
|
|
if (!defined($oFileCopyMap{&MANIFEST_TARGET_PGDATA}{&MANIFEST_FILE_PGCONTROL}) && optionGet(OPTION_ONLINE))
|
2016-02-15 03:42:11 +02:00
|
|
|
{
|
2016-05-14 16:33:12 +02:00
|
|
|
confess &log(ERROR, DB_FILE_PGCONTROL . " must be present in all online backups\n" .
|
2016-05-14 16:36:35 +02:00
|
|
|
'HINT: is something wrong with the clock or filesystem timestamps?', ERROR_FILE_MISSING);
|
2016-02-15 03:42:11 +02:00
|
|
|
}
|
|
|
|
|
2015-04-07 13:34:37 +02:00
|
|
|
# If there are no files to backup then we'll exit with a warning unless in test mode. The other way this could happen is if
|
2016-02-20 02:32:02 +02:00
|
|
|
# the database is down and backup is called with --no-online twice in a row.
|
2015-04-07 13:34:37 +02:00
|
|
|
if ($lFileTotal == 0)
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2015-04-07 13:34:37 +02:00
|
|
|
if (!optionGet(OPTION_TEST))
|
|
|
|
{
|
2016-02-15 03:42:11 +02:00
|
|
|
confess &log(ERROR, "no files have changed since the last backup - this seems unlikely", ERROR_FILE_MISSING);
|
2015-04-07 13:34:37 +02:00
|
|
|
}
|
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
# Create backup and result queues
|
|
|
|
my $oResultQueue = Thread::Queue->new();
|
|
|
|
my @oyBackupQueue;
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Variables used for local copy
|
|
|
|
my $lSizeCurrent = 0; # Running total of bytes copied
|
|
|
|
my $bCopied; # Was the file copied?
|
|
|
|
my $lCopySize; # Size reported by copy
|
2016-04-15 04:50:02 +02:00
|
|
|
my $lRepoSize; # Size of file in repository
|
2015-08-29 20:20:46 +02:00
|
|
|
my $strCopyChecksum; # Checksum reported by copy
|
2015-05-07 02:24:34 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Determine how often the manifest will be saved
|
|
|
|
my $lManifestSaveCurrent = 0;
|
|
|
|
my $lManifestSaveSize = int($lSizeTotal / 100);
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2016-02-15 03:42:11 +02:00
|
|
|
if (optionSource(OPTION_MANIFEST_SAVE_THRESHOLD) ne SOURCE_DEFAULT ||
|
|
|
|
$lManifestSaveSize < optionGet(OPTION_MANIFEST_SAVE_THRESHOLD))
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
$lManifestSaveSize = optionGet(OPTION_MANIFEST_SAVE_THRESHOLD);
|
2015-04-07 13:34:37 +02:00
|
|
|
}
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-12-24 17:32:25 +02:00
|
|
|
# Start backup test point
|
|
|
|
&log(TEST, TEST_BACKUP_START);
|
2015-10-08 17:43:56 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Iterate all backup files
|
2016-04-15 04:50:02 +02:00
|
|
|
foreach my $strTargetKey (sort(keys(%oFileCopyMap)))
|
2015-04-07 13:34:37 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
if (optionGet(OPTION_THREAD_MAX) > 1)
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
$oyBackupQueue[@oyBackupQueue] = Thread::Queue->new();
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
foreach my $strFileKey (sort {$b cmp $a} (keys(%{$oFileCopyMap{$strTargetKey}})))
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
my $oFileCopy = $oFileCopyMap{$strTargetKey}{$strFileKey};
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-02-15 03:42:11 +02:00
|
|
|
# Skip files marked to be copied later
|
|
|
|
next if $$oFileCopy{skip};
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
if (optionGet(OPTION_THREAD_MAX) > 1)
|
|
|
|
{
|
|
|
|
$oyBackupQueue[@oyBackupQueue - 1]->enqueue($oFileCopy);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# Backup the file
|
2016-04-15 04:50:02 +02:00
|
|
|
($bCopied, $lSizeCurrent, $lCopySize, $lRepoSize, $strCopyChecksum) =
|
|
|
|
backupFile($self->{oFile}, $$oFileCopy{db_file}, $$oFileCopy{repo_file}, $bCompress, $$oFileCopy{checksum},
|
|
|
|
$$oFileCopy{modification_time}, $$oFileCopy{size}, $lSizeTotal, $lSizeCurrent);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
$lManifestSaveCurrent = backupManifestUpdate($oBackupManifest, $$oFileCopy{repo_file}, $bCopied, $lCopySize,
|
|
|
|
$lRepoSize, $strCopyChecksum, $lManifestSaveSize,
|
2015-08-29 20:20:46 +02:00
|
|
|
$lManifestSaveCurrent);
|
|
|
|
}
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# If multi-threaded then create threads to copy files
|
|
|
|
if (optionGet(OPTION_THREAD_MAX) > 1)
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2015-09-08 13:31:24 +02:00
|
|
|
# Load module dynamically
|
2016-04-14 15:30:54 +02:00
|
|
|
require pgBackRest::Protocol::ThreadGroup;
|
|
|
|
pgBackRest::Protocol::ThreadGroup->import();
|
2015-09-08 13:31:24 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
for (my $iThreadIdx = 0; $iThreadIdx < optionGet(OPTION_THREAD_MAX); $iThreadIdx++)
|
|
|
|
{
|
|
|
|
my %oParam;
|
2015-04-07 13:34:37 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
$oParam{compress} = $bCompress;
|
|
|
|
$oParam{queue} = \@oyBackupQueue;
|
|
|
|
$oParam{result_queue} = $oResultQueue;
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-12-24 17:32:25 +02:00
|
|
|
# Keep the protocol layer from timing out
|
|
|
|
protocolGet()->keepAlive();
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
threadGroupRun($iThreadIdx, 'backup', \%oParam);
|
|
|
|
}
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-12-24 17:32:25 +02:00
|
|
|
# Keep the protocol layer from timing out
|
|
|
|
protocolGet()->keepAlive();
|
|
|
|
|
2015-10-08 17:43:56 +02:00
|
|
|
# Start backup test point
|
|
|
|
&log(TEST, TEST_BACKUP_START);
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Complete thread queues
|
|
|
|
my $bDone = false;
|
2015-05-07 02:24:34 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
do
|
2015-05-07 02:24:34 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
$bDone = threadGroupComplete();
|
|
|
|
|
|
|
|
# Read the messages that are passed back from the backup threads
|
|
|
|
while (my $oMessage = $oResultQueue->dequeue_nb())
|
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
&log(TRACE, "message received in master queue: file = $$oMessage{repo_file}, copied = $$oMessage{copied}");
|
2014-05-13 18:23:15 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
$lManifestSaveCurrent = backupManifestUpdate($oBackupManifest, $$oMessage{repo_file}, $$oMessage{copied},
|
|
|
|
$$oMessage{size}, $$oMessage{repo_size}, $$oMessage{checksum},
|
|
|
|
$lManifestSaveSize, $lManifestSaveCurrent);
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
2015-12-24 17:32:25 +02:00
|
|
|
|
|
|
|
# Keep the protocol layer from timing out
|
|
|
|
protocolGet()->keepAlive();
|
2015-05-07 02:24:34 +02:00
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
while (!$bDone);
|
2014-10-15 04:44:42 +03:00
|
|
|
}
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
2015-05-07 02:24:34 +02:00
|
|
|
|
2016-02-15 03:42:11 +02:00
|
|
|
# Copy pg_control last - this is required for backups taken during recovery
|
2016-04-15 04:50:02 +02:00
|
|
|
my $oFileCopy = $oFileCopyMap{&MANIFEST_TARGET_PGDATA}{&MANIFEST_FILE_PGCONTROL};
|
2016-02-15 03:42:11 +02:00
|
|
|
|
|
|
|
if (defined($oFileCopy))
|
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
my ($bCopied, $lSizeCurrent, $lCopySize, $lRepoSize, $strCopyChecksum) =
|
|
|
|
backupFile($self->{oFile}, $$oFileCopy{db_file}, $$oFileCopy{repo_file}, $bCompress, $$oFileCopy{checksum},
|
|
|
|
$$oFileCopy{modification_time}, $$oFileCopy{size});
|
2016-02-15 03:42:11 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
backupManifestUpdate($oBackupManifest, $$oFileCopy{repo_file}, $bCopied, $lCopySize, $lRepoSize, $strCopyChecksum);
|
2016-02-15 03:42:11 +02:00
|
|
|
|
|
|
|
$lSizeTotal += $$oFileCopy{size};
|
|
|
|
}
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'lSizeTotal', value => $lSizeTotal}
|
|
|
|
);
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
# process
|
2014-06-04 18:58:30 +03:00
|
|
|
#
|
2015-08-29 20:20:46 +02:00
|
|
|
# Process the database backup.
|
2014-03-06 03:53:13 +03:00
|
|
|
####################################################################################################################################
|
2015-08-29 20:20:46 +02:00
|
|
|
sub process
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
|
|
|
OP_BACKUP_PROCESS
|
|
|
|
);
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-06-14 00:25:49 +02:00
|
|
|
# Record timestamp start
|
|
|
|
my $lTimestampStart = time();
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Store local type, compress, and hardlink options since they can be modified by the process
|
|
|
|
my $strType = optionGet(OPTION_TYPE);
|
|
|
|
my $bCompress = optionGet(OPTION_COMPRESS);
|
|
|
|
my $bHardLink = optionGet(OPTION_HARDLINK);
|
2015-05-26 18:26:59 +02:00
|
|
|
|
2014-03-06 03:53:13 +03:00
|
|
|
# Not supporting remote backup hosts yet
|
2015-08-29 20:20:46 +02:00
|
|
|
if ($self->{oFile}->isRemote(PATH_BACKUP))
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2014-09-16 15:55:40 +03:00
|
|
|
confess &log(ERROR, 'remote backup host not currently supported');
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# Create the cluster backup and history path
|
|
|
|
$self->{oFile}->pathCreate(PATH_BACKUP_CLUSTER, PATH_BACKUP_HISTORY, undef, true, true);
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-06-14 00:25:49 +02:00
|
|
|
# Load or build backup.info
|
2016-04-14 15:30:54 +02:00
|
|
|
my $oBackupInfo = new pgBackRest::BackupInfo($self->{oFile}->pathGet(PATH_BACKUP_CLUSTER));
|
2015-06-14 00:25:49 +02:00
|
|
|
|
2015-01-20 21:42:22 +02:00
|
|
|
# Build backup tmp and config
|
2015-08-29 20:20:46 +02:00
|
|
|
my $strBackupTmpPath = $self->{oFile}->pathGet(PATH_BACKUP_TMP);
|
|
|
|
my $strBackupConfFile = $self->{oFile}->pathGet(PATH_BACKUP_TMP, 'backup.manifest');
|
2015-01-20 21:42:22 +02:00
|
|
|
|
2014-09-18 23:42:13 +03:00
|
|
|
# Declare the backup manifest
|
2016-04-14 15:30:54 +02:00
|
|
|
my $oBackupManifest = new pgBackRest::Manifest($strBackupConfFile, false);
|
2014-09-18 23:42:13 +03:00
|
|
|
|
2014-03-06 03:53:13 +03:00
|
|
|
# Find the previous backup based on the type
|
2016-04-15 04:50:02 +02:00
|
|
|
my $oLastManifest;
|
|
|
|
my $strBackupLastPath;
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
if ($strType ne BACKUP_TYPE_FULL)
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
$strBackupLastPath = $oBackupInfo->last($strType eq BACKUP_TYPE_DIFF ? BACKUP_TYPE_FULL : BACKUP_TYPE_INCR);
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
if (defined($strBackupLastPath))
|
2015-08-29 20:20:46 +02:00
|
|
|
{
|
2016-04-15 04:50:02 +02:00
|
|
|
$oLastManifest = new pgBackRest::Manifest(
|
|
|
|
$self->{oFile}->pathGet(PATH_BACKUP_CLUSTER, "${strBackupLastPath}/" . FILE_MANIFEST));
|
|
|
|
|
|
|
|
&log(INFO, 'last backup label = ' . $oLastManifest->get(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_LABEL) .
|
|
|
|
', version = ' . $oLastManifest->get(INI_SECTION_BACKREST, INI_KEY_VERSION));
|
|
|
|
|
|
|
|
# If this is incr or diff warn if certain options have changed
|
2015-08-29 20:20:46 +02:00
|
|
|
my $strKey;
|
|
|
|
|
|
|
|
# Warn if compress option changed
|
|
|
|
if (!$oLastManifest->boolTest(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_COMPRESS, undef, $bCompress))
|
|
|
|
{
|
|
|
|
&log(WARN, "${strType} backup cannot alter compress option to '" . boolFormat($bCompress) .
|
|
|
|
"', reset to value in ${strBackupLastPath}");
|
|
|
|
$bCompress = $oLastManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_COMPRESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Warn if hardlink option changed
|
|
|
|
if (!$oLastManifest->boolTest(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_HARDLINK, undef, $bHardLink))
|
|
|
|
{
|
|
|
|
&log(WARN, "${strType} backup cannot alter hardlink option to '" . boolFormat($bHardLink) .
|
|
|
|
"', reset to value in ${strBackupLastPath}");
|
|
|
|
$bHardLink = $oLastManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_HARDLINK);
|
|
|
|
}
|
|
|
|
}
|
2016-04-15 04:50:02 +02:00
|
|
|
else
|
2014-10-14 15:27:50 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
&log(WARN, "no prior backup exists, ${strType} backup has been changed to full");
|
2016-04-15 04:50:02 +02:00
|
|
|
$strType = BACKUP_TYPE_FULL;
|
2014-10-14 15:27:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-21 01:00:03 +02:00
|
|
|
# Backup settings
|
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_TYPE, undef, $strType);
|
2015-08-29 20:20:46 +02:00
|
|
|
$oBackupManifest->numericSet(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_TIMESTAMP_START, undef, $lTimestampStart);
|
|
|
|
$oBackupManifest->boolSet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_COMPRESS, undef, $bCompress);
|
|
|
|
$oBackupManifest->boolSet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_HARDLINK, undef, $bHardLink);
|
2016-02-20 02:32:02 +02:00
|
|
|
$oBackupManifest->boolSet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_ONLINE, undef, optionGet(OPTION_ONLINE));
|
2015-08-29 20:20:46 +02:00
|
|
|
$oBackupManifest->boolSet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_ARCHIVE_COPY, undef,
|
2016-02-20 02:32:02 +02:00
|
|
|
!optionGet(OPTION_ONLINE) ||
|
2016-01-04 03:21:30 +02:00
|
|
|
(optionGet(OPTION_BACKUP_ARCHIVE_CHECK) && optionGet(OPTION_BACKUP_ARCHIVE_COPY)));
|
2015-08-29 20:20:46 +02:00
|
|
|
$oBackupManifest->boolSet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_ARCHIVE_CHECK, undef,
|
2016-02-20 02:32:02 +02:00
|
|
|
!optionGet(OPTION_ONLINE) || optionGet(OPTION_BACKUP_ARCHIVE_CHECK));
|
2015-06-14 00:25:49 +02:00
|
|
|
|
|
|
|
# Database info
|
2016-05-14 16:33:12 +02:00
|
|
|
my ($strDbVersion, $iControlVersion, $iCatalogVersion, $ullDbSysId) =
|
2015-08-29 20:20:46 +02:00
|
|
|
$self->{oDb}->info($self->{oFile}, optionGet(OPTION_DB_PATH));
|
2015-06-14 00:25:49 +02:00
|
|
|
|
2016-05-14 16:33:12 +02:00
|
|
|
my $iDbHistoryId = $oBackupInfo->check($strDbVersion, $iControlVersion, $iCatalogVersion, $ullDbSysId);
|
2015-09-02 01:05:10 +02:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
$oBackupManifest->numericSet(MANIFEST_SECTION_BACKUP_DB, MANIFEST_KEY_DB_ID, undef, $iDbHistoryId);
|
2016-05-14 16:33:12 +02:00
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_BACKUP_DB, MANIFEST_KEY_DB_VERSION, undef, $strDbVersion);
|
2015-08-29 20:20:46 +02:00
|
|
|
$oBackupManifest->numericSet(MANIFEST_SECTION_BACKUP_DB, MANIFEST_KEY_CONTROL, undef, $iControlVersion);
|
|
|
|
$oBackupManifest->numericSet(MANIFEST_SECTION_BACKUP_DB, MANIFEST_KEY_CATALOG, undef, $iCatalogVersion);
|
|
|
|
$oBackupManifest->numericSet(MANIFEST_SECTION_BACKUP_DB, MANIFEST_KEY_SYSTEM_ID, undef, $ullDbSysId);
|
2015-06-14 00:25:49 +02:00
|
|
|
|
2016-02-20 02:32:02 +02:00
|
|
|
# Start backup (unless --no-online is set)
|
2014-09-20 00:51:51 +03:00
|
|
|
my $strArchiveStart;
|
2015-08-29 20:20:46 +02:00
|
|
|
my $oTablespaceMap;
|
2016-05-11 15:21:39 +02:00
|
|
|
my $oDatabaseMap;
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Don't start the backup but do check if PostgreSQL is running
|
2016-02-20 02:32:02 +02:00
|
|
|
if (!optionGet(OPTION_ONLINE))
|
2014-09-20 00:51:51 +03:00
|
|
|
{
|
2016-05-14 16:33:12 +02:00
|
|
|
if ($self->{oFile}->exists(PATH_DB_ABSOLUTE, optionGet(OPTION_DB_PATH) . '/' . DB_FILE_POSTMASTERPID))
|
2014-09-20 00:51:51 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
if (optionGet(OPTION_FORCE))
|
2014-09-20 00:51:51 +03:00
|
|
|
{
|
2016-05-14 16:33:12 +02:00
|
|
|
&log(WARN, '--no-online passed and ' . DB_FILE_POSTMASTERPID . ' exists but --force was passed so backup will ' .
|
2014-12-19 00:05:06 +02:00
|
|
|
'continue though it looks like the postmaster is running and the backup will probably not be ' .
|
|
|
|
'consistent');
|
2014-09-20 00:51:51 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-14 16:33:12 +02:00
|
|
|
confess &log(ERROR, '--no-online passed but ' . DB_FILE_POSTMASTERPID . ' exists - looks like the postmaster is ' .
|
2015-09-09 00:29:13 +02:00
|
|
|
'running. Shutdown the postmaster and try again, or use --force.', ERROR_POSTMASTER_RUNNING);
|
2014-09-20 00:51:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
# Else start the backup normally
|
2014-09-20 00:51:51 +03:00
|
|
|
else
|
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
# Start the backup
|
2016-05-14 16:33:12 +02:00
|
|
|
($strArchiveStart) =
|
|
|
|
$self->{oDb}->backupStart($self->{oFile}, optionGet(OPTION_DB_PATH), BACKREST_NAME . ' backup started at ' .
|
2015-08-29 20:20:46 +02:00
|
|
|
timestampFormat(undef, $lTimestampStart), optionGet(OPTION_START_FAST));
|
2015-01-21 01:00:03 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Record the archive start location
|
2015-01-21 01:00:03 +02:00
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_ARCHIVE_START, undef, $strArchiveStart);
|
|
|
|
&log(INFO, "archive start: ${strArchiveStart}");
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2016-05-11 15:21:39 +02:00
|
|
|
# Get tablespace map
|
2016-02-20 02:32:02 +02:00
|
|
|
$oTablespaceMap = $self->{oDb}->tablespaceMapGet();
|
2016-05-11 15:21:39 +02:00
|
|
|
|
|
|
|
# Get database map
|
|
|
|
$oDatabaseMap = $self->{oDb}->databaseMapGet();
|
2015-08-29 20:20:46 +02:00
|
|
|
}
|
2014-09-20 00:51:51 +03:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Buid the manifest
|
2016-02-20 02:32:02 +02:00
|
|
|
$oBackupManifest->build($self->{oFile}, optionGet(OPTION_DB_PATH), $oLastManifest, optionGet(OPTION_ONLINE),
|
2016-05-11 15:21:39 +02:00
|
|
|
$oTablespaceMap, $oDatabaseMap);
|
2014-07-28 01:13:23 +03:00
|
|
|
&log(TEST, TEST_MANIFEST_BUILD);
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2014-10-14 15:27:50 +03:00
|
|
|
# Check if an aborted backup exists for this stanza
|
2014-03-06 03:53:13 +03:00
|
|
|
if (-e $strBackupTmpPath)
|
|
|
|
{
|
2014-10-14 15:27:50 +03:00
|
|
|
my $bUsable = false;
|
2015-08-29 20:20:46 +02:00
|
|
|
my $strReason = "resume is disabled";
|
2015-01-23 00:43:19 +02:00
|
|
|
my $oAbortedManifest;
|
2015-01-22 17:54:02 +02:00
|
|
|
|
2016-05-14 16:33:12 +02:00
|
|
|
# Attempt to read the manifest file in the aborted backup to see if it can be used. If any error at all occurs then the
|
2015-08-29 20:20:46 +02:00
|
|
|
# backup will be considered unusable and a resume will not be attempted.
|
|
|
|
if (optionGet(OPTION_RESUME))
|
2014-10-14 15:27:50 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
$strReason = "unable to read ${strBackupTmpPath}/backup.manifest";
|
|
|
|
|
|
|
|
eval
|
2014-10-14 15:27:50 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
# Load the aborted manifest
|
2016-04-14 15:30:54 +02:00
|
|
|
$oAbortedManifest = new pgBackRest::Manifest("${strBackupTmpPath}/backup.manifest");
|
2015-08-29 20:20:46 +02:00
|
|
|
|
|
|
|
# Key and values that do not match
|
|
|
|
my $strKey;
|
|
|
|
my $strValueNew;
|
|
|
|
my $strValueAborted;
|
|
|
|
|
|
|
|
# Check version
|
|
|
|
if ($oBackupManifest->get(INI_SECTION_BACKREST, INI_KEY_VERSION) ne
|
|
|
|
$oAbortedManifest->get(INI_SECTION_BACKREST, INI_KEY_VERSION))
|
2014-10-14 22:44:50 +03:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
$strKey = INI_KEY_VERSION;
|
|
|
|
$strValueNew = $oBackupManifest->get(INI_SECTION_BACKREST, INI_KEY_VERSION);
|
|
|
|
$strValueAborted = $oAbortedManifest->get(INI_SECTION_BACKREST, INI_KEY_VERSION);
|
|
|
|
}
|
|
|
|
# Check format
|
|
|
|
elsif ($oBackupManifest->get(INI_SECTION_BACKREST, INI_KEY_FORMAT) ne
|
|
|
|
$oAbortedManifest->get(INI_SECTION_BACKREST, INI_KEY_FORMAT))
|
|
|
|
{
|
|
|
|
$strKey = INI_KEY_FORMAT;
|
|
|
|
$strValueNew = $oBackupManifest->get(INI_SECTION_BACKREST, INI_KEY_FORMAT);
|
|
|
|
$strValueAborted = $oAbortedManifest->get(INI_SECTION_BACKREST, INI_KEY_FORMAT);
|
|
|
|
}
|
|
|
|
# Check backup type
|
|
|
|
elsif ($oBackupManifest->get(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_TYPE) ne
|
|
|
|
$oAbortedManifest->get(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_TYPE))
|
|
|
|
{
|
|
|
|
$strKey = MANIFEST_KEY_TYPE;
|
|
|
|
$strValueNew = $oBackupManifest->get(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_TYPE);
|
|
|
|
$strValueAborted = $oAbortedManifest->get(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_TYPE);
|
|
|
|
}
|
|
|
|
# Check prior label
|
|
|
|
elsif ($oBackupManifest->get(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_PRIOR, undef, false, '<undef>') ne
|
|
|
|
$oAbortedManifest->get(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_PRIOR, undef, false, '<undef>'))
|
|
|
|
{
|
|
|
|
$strKey = MANIFEST_KEY_PRIOR;
|
|
|
|
$strValueNew = $oBackupManifest->get(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_PRIOR, undef, false, '<undef>');
|
|
|
|
$strValueAborted = $oAbortedManifest->get(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_PRIOR, undef, false, '<undef>');
|
|
|
|
}
|
|
|
|
# Check compression
|
|
|
|
elsif ($oBackupManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_COMPRESS) ne
|
|
|
|
$oAbortedManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_COMPRESS))
|
|
|
|
{
|
|
|
|
$strKey = MANIFEST_KEY_COMPRESS;
|
|
|
|
$strValueNew = $oBackupManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_COMPRESS);
|
|
|
|
$strValueAborted = $oAbortedManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_COMPRESS);
|
2014-10-14 22:44:50 +03:00
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
# Check hardlink
|
|
|
|
elsif ($oBackupManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_HARDLINK) ne
|
|
|
|
$oAbortedManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_HARDLINK))
|
|
|
|
{
|
|
|
|
$strKey = MANIFEST_KEY_HARDLINK;
|
|
|
|
$strValueNew = $oBackupManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_HARDLINK);
|
|
|
|
$strValueAborted = $oAbortedManifest->boolGet(MANIFEST_SECTION_BACKUP_OPTION, MANIFEST_KEY_HARDLINK);
|
|
|
|
}
|
|
|
|
|
|
|
|
# If key is defined then something didn't match
|
|
|
|
if (defined($strKey))
|
|
|
|
{
|
|
|
|
$strReason = "new ${strKey} '${strValueNew}' does not match aborted ${strKey} '${strValueAborted}'";
|
|
|
|
}
|
|
|
|
# Else the backup can be resumed
|
|
|
|
else
|
2014-10-14 15:27:50 +03:00
|
|
|
{
|
|
|
|
$bUsable = true;
|
|
|
|
}
|
2015-08-29 20:20:46 +02:00
|
|
|
};
|
|
|
|
}
|
2014-06-04 18:58:30 +03:00
|
|
|
|
2014-10-14 15:27:50 +03:00
|
|
|
# If the aborted backup is usable then clean it
|
2015-08-29 20:20:46 +02:00
|
|
|
if ($bUsable)
|
2014-10-14 15:27:50 +03:00
|
|
|
{
|
|
|
|
&log(WARN, 'aborted backup of same type exists, will be cleaned to remove invalid files and resumed');
|
2015-01-22 17:54:02 +02:00
|
|
|
&log(TEST, TEST_BACKUP_RESUME);
|
2014-10-14 15:27:50 +03:00
|
|
|
|
|
|
|
# Clean the old backup tmp path
|
2015-08-29 20:20:46 +02:00
|
|
|
$self->tmpClean($oBackupManifest, $oAbortedManifest);
|
2014-10-14 15:27:50 +03:00
|
|
|
}
|
|
|
|
# Else remove it
|
|
|
|
else
|
|
|
|
{
|
2015-01-22 17:54:02 +02:00
|
|
|
&log(WARN, "aborted backup exists, but cannot be resumed (${strReason}) - will be dropped and recreated");
|
|
|
|
&log(TEST, TEST_BACKUP_NORESUME);
|
2014-10-14 15:27:50 +03:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
remove_tree($self->{oFile}->pathGet(PATH_BACKUP_TMP))
|
2014-10-14 15:27:50 +03:00
|
|
|
or confess &log(ERROR, "unable to delete tmp path: ${strBackupTmpPath}");
|
2016-04-15 04:50:02 +02:00
|
|
|
$self->{oFile}->pathCreate(PATH_BACKUP_TMP, undef, undef, false, true);
|
2014-10-14 15:27:50 +03:00
|
|
|
}
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
# Else create the backup tmp path
|
|
|
|
else
|
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
logDebugMisc($strOperation, "create temp backup path ${strBackupTmpPath}");
|
2016-04-15 04:50:02 +02:00
|
|
|
$self->{oFile}->pathCreate(PATH_BACKUP_TMP, undef, undef, false, true);
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
|
2015-01-20 21:42:22 +02:00
|
|
|
# Save the backup manifest
|
|
|
|
$oBackupManifest->save();
|
2014-03-06 03:53:13 +03:00
|
|
|
|
|
|
|
# Perform the backup
|
2016-04-15 04:50:02 +02:00
|
|
|
my $lBackupSizeTotal = $self->processManifest(optionGet(OPTION_DB_PATH), $strType, $bCompress, $bHardLink, $oBackupManifest);
|
2015-08-29 20:20:46 +02:00
|
|
|
&log(INFO, "${strType} backup size = " . fileSizeFormat($lBackupSizeTotal));
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2016-02-20 02:32:02 +02:00
|
|
|
# Stop backup (unless --no-online is set)
|
2014-09-20 00:51:51 +03:00
|
|
|
my $strArchiveStop;
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2016-02-20 02:32:02 +02:00
|
|
|
if (optionGet(OPTION_ONLINE))
|
2014-09-20 00:51:51 +03:00
|
|
|
{
|
2016-05-14 16:33:12 +02:00
|
|
|
($strArchiveStop) = $self->{oDb}->backupStop();
|
2015-01-21 01:00:03 +02:00
|
|
|
|
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_ARCHIVE_STOP, undef, $strArchiveStop);
|
|
|
|
|
|
|
|
&log(INFO, 'archive stop: ' . $strArchiveStop);
|
2014-09-20 00:51:51 +03:00
|
|
|
}
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-05-07 02:24:34 +02:00
|
|
|
# If archive logs are required to complete the backup, then check them. This is the default, but can be overridden if the
|
2016-02-20 02:32:02 +02:00
|
|
|
# archive logs are going to a different server. Be careful of this option because there is no way to verify that the backup
|
|
|
|
# will be consistent - at least not here.
|
|
|
|
if (optionGet(OPTION_ONLINE) && optionGet(OPTION_BACKUP_ARCHIVE_CHECK))
|
2014-03-06 03:53:13 +03:00
|
|
|
{
|
2015-01-20 21:42:22 +02:00
|
|
|
# Save the backup manifest a second time - before getting archive logs in case that fails
|
|
|
|
$oBackupManifest->save();
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-01-27 18:44:23 +02:00
|
|
|
# Create the modification time for the archive logs
|
|
|
|
my $lModificationTime = time();
|
|
|
|
|
2014-03-06 03:53:13 +03:00
|
|
|
# After the backup has been stopped, need to make a copy of the archive logs need to make the db consistent
|
2015-08-29 20:20:46 +02:00
|
|
|
logDebugMisc($strOperation, "retrieve archive logs ${strArchiveStart}:${strArchiveStop}");
|
2016-04-14 15:30:54 +02:00
|
|
|
my $oArchive = new pgBackRest::Archive();
|
2015-08-29 20:20:46 +02:00
|
|
|
my $strArchiveId = $oArchive->getCheck($self->{oFile});
|
2016-05-14 16:33:12 +02:00
|
|
|
my @stryArchive = $oArchive->range($strArchiveStart, $strArchiveStop, $strDbVersion < PG_VERSION_93);
|
2014-03-06 03:53:13 +03:00
|
|
|
|
|
|
|
foreach my $strArchive (@stryArchive)
|
|
|
|
{
|
2016-01-10 06:08:54 +02:00
|
|
|
my $strArchiveFile = $oArchive->walFileName($self->{oFile}, $strArchiveId, $strArchive, false, 600);
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-03-23 22:01:15 +02:00
|
|
|
if (optionGet(OPTION_BACKUP_ARCHIVE_COPY))
|
2015-03-16 20:45:53 +02:00
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
logDebugMisc($strOperation, "archive: ${strArchive} (${strArchiveFile})");
|
2015-03-16 20:45:53 +02:00
|
|
|
|
|
|
|
# Copy the log file from the archive repo to the backup
|
2016-04-15 04:50:02 +02:00
|
|
|
my $strDestinationFile = MANIFEST_TARGET_PGDATA . "/pg_xlog/${strArchive}" .
|
|
|
|
($bCompress ? ".$self->{oFile}->{strCompressExtension}" : '');
|
2015-08-29 20:20:46 +02:00
|
|
|
my $bArchiveCompressed = $strArchiveFile =~ "^.*\.$self->{oFile}->{strCompressExtension}\$";
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-03-16 20:45:53 +02:00
|
|
|
my ($bCopyResult, $strCopyChecksum, $lCopySize) =
|
2015-08-29 20:20:46 +02:00
|
|
|
$self->{oFile}->copy(PATH_BACKUP_ARCHIVE, "${strArchiveId}/${strArchiveFile}",
|
2015-03-16 20:45:53 +02:00
|
|
|
PATH_BACKUP_TMP, $strDestinationFile,
|
2015-05-22 20:49:14 +02:00
|
|
|
$bArchiveCompressed, $bCompress,
|
|
|
|
undef, $lModificationTime, undef, true);
|
2015-01-27 18:44:23 +02:00
|
|
|
|
2015-03-16 20:45:53 +02:00
|
|
|
# Add the archive file to the manifest so it can be part of the restore and checked in validation
|
2016-04-15 04:50:02 +02:00
|
|
|
my $strPathLog = MANIFEST_TARGET_PGDATA . '/pg_xlog';
|
|
|
|
my $strFileLog = "${strPathLog}/${strArchive}";
|
2015-01-27 18:44:23 +02:00
|
|
|
|
2015-03-16 20:45:53 +02:00
|
|
|
# Compare the checksum against the one already in the archive log name
|
2015-08-29 20:20:46 +02:00
|
|
|
if ($strArchiveFile !~ "^${strArchive}-${strCopyChecksum}(\\.$self->{oFile}->{strCompressExtension}){0,1}\$")
|
2015-03-16 20:45:53 +02:00
|
|
|
{
|
2015-04-01 21:58:33 +02:00
|
|
|
confess &log(ERROR, "error copying WAL segment '${strArchiveFile}' to backup - checksum recorded with " .
|
|
|
|
"file does not match actual checksum of '${strCopyChecksum}'", ERROR_CHECKSUM);
|
2015-03-16 20:45:53 +02:00
|
|
|
}
|
2015-01-27 18:44:23 +02:00
|
|
|
|
2015-03-16 20:45:53 +02:00
|
|
|
# Set manifest values
|
2016-04-15 04:50:02 +02:00
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_TARGET_FILE, $strFileLog, MANIFEST_SUBKEY_USER,
|
|
|
|
$oBackupManifest->get(MANIFEST_SECTION_TARGET_PATH, $strPathLog, MANIFEST_SUBKEY_USER));
|
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_TARGET_FILE, $strFileLog, MANIFEST_SUBKEY_GROUP,
|
|
|
|
$oBackupManifest->get(MANIFEST_SECTION_TARGET_PATH, $strPathLog, MANIFEST_SUBKEY_GROUP));
|
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_TARGET_FILE, $strFileLog, MANIFEST_SUBKEY_MODE, '0700');
|
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_TARGET_FILE, $strFileLog, MANIFEST_SUBKEY_TIMESTAMP, $lModificationTime);
|
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_TARGET_FILE, $strFileLog, MANIFEST_SUBKEY_SIZE, $lCopySize);
|
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_TARGET_FILE, $strFileLog, MANIFEST_SUBKEY_CHECKSUM, $strCopyChecksum);
|
|
|
|
$oBackupManifest->buildDefault();
|
2015-01-27 18:44:23 +02:00
|
|
|
}
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-13 02:17:16 +03:00
|
|
|
# Create the path for the new backup
|
2015-06-14 00:25:49 +02:00
|
|
|
my $lTimestampStop = time();
|
2015-09-02 01:05:10 +02:00
|
|
|
my $strBackupLabel = backupLabelFormat($strType, $strBackupLastPath, $lTimestampStop);
|
2014-08-13 02:17:16 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# Make sure that the timestamp has not already been used by a prior backup. This is unlikely for online backups since there is
|
|
|
|
# already a wait after the manifest is built but it's still possible if the remote and local systems don't have synchronized
|
|
|
|
# clocks. In practice this is most useful for making offline testing faster since it allows the wait after manifest build to
|
|
|
|
# be skipped by dealing with any backup label collisions here.
|
|
|
|
if (fileList($self->{oFile}->pathGet(PATH_BACKUP_CLUSTER),
|
|
|
|
($strType eq BACKUP_TYPE_FULL ? '^' : '_') .
|
|
|
|
timestampFileFormat(undef, $lTimestampStop) .
|
|
|
|
($strType eq BACKUP_TYPE_FULL ? 'F' : '(D|I)$')) ||
|
|
|
|
fileList($self->{oFile}->pathGet(PATH_BACKUP_CLUSTER, PATH_BACKUP_HISTORY . '/' . timestampFormat('%4d', $lTimestampStop)),
|
|
|
|
($strType eq BACKUP_TYPE_FULL ? '^' : '_') .
|
|
|
|
timestampFileFormat(undef, $lTimestampStop) .
|
|
|
|
($strType eq BACKUP_TYPE_FULL ? 'F' : '(D|I)\.manifest\.gz$'), undef, true))
|
|
|
|
{
|
|
|
|
waitRemainder();
|
|
|
|
$strBackupLabel = backupLabelFormat($strType, $strBackupLastPath, time());
|
|
|
|
}
|
|
|
|
|
2014-08-13 02:04:46 +03:00
|
|
|
# Record timestamp stop in the config
|
2015-06-14 00:25:49 +02:00
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_TIMESTAMP_STOP, undef, $lTimestampStop + 0);
|
2015-09-02 01:05:10 +02:00
|
|
|
$oBackupManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_LABEL, undef, $strBackupLabel);
|
2014-08-13 02:04:46 +03:00
|
|
|
|
2016-05-11 15:21:39 +02:00
|
|
|
# Final save of the backup manifest
|
2015-01-20 21:42:22 +02:00
|
|
|
$oBackupManifest->save();
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-09-02 01:05:10 +02:00
|
|
|
&log(INFO, "new backup label = ${strBackupLabel}");
|
2014-08-13 02:17:16 +03:00
|
|
|
|
2016-04-15 04:50:02 +02:00
|
|
|
# Make a compressed copy of the manifest for history
|
|
|
|
$self->{oFile}->copy(PATH_BACKUP_TMP, FILE_MANIFEST,
|
|
|
|
PATH_BACKUP_TMP, FILE_MANIFEST . '.gz',
|
|
|
|
undef, true);
|
|
|
|
|
|
|
|
# Move the backup tmp path to complete the backup
|
2015-09-02 01:05:10 +02:00
|
|
|
logDebugMisc($strOperation, "move ${strBackupTmpPath} to " . $self->{oFile}->pathGet(PATH_BACKUP_CLUSTER, $strBackupLabel));
|
|
|
|
$self->{oFile}->move(PATH_BACKUP_TMP, undef, PATH_BACKUP_CLUSTER, $strBackupLabel);
|
2014-12-18 18:14:30 +02:00
|
|
|
|
2016-05-11 15:21:39 +02:00
|
|
|
# Copy manifest to history
|
2016-04-15 04:50:02 +02:00
|
|
|
$self->{oFile}->move(PATH_BACKUP_CLUSTER, "${strBackupLabel}/" . FILE_MANIFEST . '.gz',
|
|
|
|
PATH_BACKUP_CLUSTER, PATH_BACKUP_HISTORY . qw{/} . substr($strBackupLabel, 0, 4) .
|
|
|
|
"/${strBackupLabel}.manifest.gz", true);
|
|
|
|
|
2014-12-18 18:14:30 +02:00
|
|
|
# Create a link to the most recent backup
|
2015-08-29 20:20:46 +02:00
|
|
|
$self->{oFile}->remove(PATH_BACKUP_CLUSTER, "latest");
|
2015-09-02 01:05:10 +02:00
|
|
|
$self->{oFile}->linkCreate(PATH_BACKUP_CLUSTER, $strBackupLabel, PATH_BACKUP_CLUSTER, "latest", undef, true);
|
2015-05-26 18:26:59 +02:00
|
|
|
|
2015-06-14 00:25:49 +02:00
|
|
|
# Save backup info
|
2016-04-15 04:50:02 +02:00
|
|
|
$oBackupInfo->add($oBackupManifest);
|
2014-03-06 03:53:13 +03:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation
|
|
|
|
);
|
2014-03-06 03:53:13 +03:00
|
|
|
}
|
|
|
|
|
2014-06-04 18:58:30 +03:00
|
|
|
1;
|