mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Improvements to manifest save.
This commit is contained in:
parent
8a7ee1bb1f
commit
44fad1f4a4
@ -1388,8 +1388,12 @@ sub backup
|
|||||||
# Create the cluster backup path
|
# Create the cluster backup path
|
||||||
$oFile->path_create(PATH_BACKUP_CLUSTER, undef, undef, true);
|
$oFile->path_create(PATH_BACKUP_CLUSTER, undef, undef, true);
|
||||||
|
|
||||||
|
# Build backup tmp and config
|
||||||
|
my $strBackupTmpPath = $oFile->path_get(PATH_BACKUP_TMP);
|
||||||
|
my $strBackupConfFile = $oFile->path_get(PATH_BACKUP_TMP, 'backup.manifest');
|
||||||
|
|
||||||
# Declare the backup manifest
|
# Declare the backup manifest
|
||||||
my $oBackupManifest = new BackRest::Manifest();
|
my $oBackupManifest = new BackRest::Manifest($strBackupConfFile, false);
|
||||||
|
|
||||||
${$oBackupManifest->{oManifest}}{'backup:option'}{'compress'} = $bCompress ? 'y' : 'n';
|
${$oBackupManifest->{oManifest}}{'backup:option'}{'compress'} = $bCompress ? 'y' : 'n';
|
||||||
${$oBackupManifest->{oManifest}}{'backup:option'}{'checksum'} = !$bNoChecksum ? 'y' : 'n';
|
${$oBackupManifest->{oManifest}}{'backup:option'}{'checksum'} = !$bNoChecksum ? 'y' : 'n';
|
||||||
@ -1432,10 +1436,6 @@ sub backup
|
|||||||
${$oBackupManifest->{oManifest}}{'backup:option'}{'hardlink'} = $bHardLink ? 'y' : 'n';
|
${$oBackupManifest->{oManifest}}{'backup:option'}{'hardlink'} = $bHardLink ? 'y' : 'n';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build backup tmp and config
|
|
||||||
my $strBackupTmpPath = $oFile->path_get(PATH_BACKUP_TMP);
|
|
||||||
my $strBackupConfFile = $oFile->path_get(PATH_BACKUP_TMP, 'backup.manifest');
|
|
||||||
|
|
||||||
# Start backup (unless no-start-stop is set)
|
# Start backup (unless no-start-stop is set)
|
||||||
${$oBackupManifest->{oManifest}}{backup}{'timestamp-start'} = $strTimestampStart;
|
${$oBackupManifest->{oManifest}}{backup}{'timestamp-start'} = $strTimestampStart;
|
||||||
my $strArchiveStart;
|
my $strArchiveStart;
|
||||||
@ -1531,7 +1531,8 @@ sub backup
|
|||||||
{
|
{
|
||||||
$bUsable = true;
|
$bUsable = true;
|
||||||
}
|
}
|
||||||
elsif ($strAbortedType eq ${$oBackupManifest->{oManifest}}{backup}{type} && $strAbortedPrior eq ${$oBackupManifest->{oManifest}}{backup}{prior})
|
elsif ($strAbortedType eq ${$oBackupManifest->{oManifest}}{backup}{type} &&
|
||||||
|
$strAbortedPrior eq ${$oBackupManifest->{oManifest}}{backup}{prior})
|
||||||
{
|
{
|
||||||
$bUsable = true;
|
$bUsable = true;
|
||||||
}
|
}
|
||||||
@ -1569,8 +1570,8 @@ sub backup
|
|||||||
print $hVersionFile version_get();
|
print $hVersionFile version_get();
|
||||||
close($hVersionFile);
|
close($hVersionFile);
|
||||||
|
|
||||||
# Save the backup conf file with the manifest
|
# Save the backup manifest
|
||||||
ini_save($strBackupConfFile, $oBackupManifest->{oManifest});
|
$oBackupManifest->save();
|
||||||
|
|
||||||
# Perform the backup
|
# Perform the backup
|
||||||
backup_file($strDbClusterPath, $oBackupManifest->{oManifest});
|
backup_file($strDbClusterPath, $oBackupManifest->{oManifest});
|
||||||
@ -1590,8 +1591,8 @@ sub backup
|
|||||||
# consistent - at least not in this routine.
|
# consistent - at least not in this routine.
|
||||||
if ($bArchiveRequired)
|
if ($bArchiveRequired)
|
||||||
{
|
{
|
||||||
# Save the backup conf file second time - before getting archive logs in case that fails
|
# Save the backup manifest a second time - before getting archive logs in case that fails
|
||||||
ini_save($strBackupConfFile, $oBackupManifest->{oManifest});
|
$oBackupManifest->save();
|
||||||
|
|
||||||
# After the backup has been stopped, need to make a copy of the archive logs need to make the db consistent
|
# After the backup has been stopped, need to make a copy of the archive logs need to make the db consistent
|
||||||
&log(DEBUG, "retrieving archive logs ${strArchiveStart}:${strArchiveStop}");
|
&log(DEBUG, "retrieving archive logs ${strArchiveStart}:${strArchiveStop}");
|
||||||
@ -1648,8 +1649,8 @@ sub backup
|
|||||||
${$oBackupManifest->{oManifest}}{backup}{'timestamp-stop'} = timestamp_string_get();
|
${$oBackupManifest->{oManifest}}{backup}{'timestamp-stop'} = timestamp_string_get();
|
||||||
${$oBackupManifest->{oManifest}}{backup}{label} = $strBackupPath;
|
${$oBackupManifest->{oManifest}}{backup}{label} = $strBackupPath;
|
||||||
|
|
||||||
# Save the backup conf file final time
|
# Save the backup manifest final time
|
||||||
ini_save($strBackupConfFile, $oBackupManifest->{oManifest});
|
$oBackupManifest->save();
|
||||||
|
|
||||||
&log(INFO, "new backup label: ${strBackupPath}");
|
&log(INFO, "new backup label: ${strBackupPath}");
|
||||||
|
|
||||||
|
@ -60,16 +60,24 @@ sub new
|
|||||||
{
|
{
|
||||||
my $class = shift; # Class name
|
my $class = shift; # Class name
|
||||||
my $strFileName = shift; # Filename to load manifest from
|
my $strFileName = shift; # Filename to load manifest from
|
||||||
|
my $bLoad = shift; # Load the manifest?
|
||||||
|
|
||||||
# Create the class hash
|
# Create the class hash
|
||||||
my $self = {};
|
my $self = {};
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
# Create the manifest hash
|
# Filename must be specified
|
||||||
$self->{oManifest} = {};
|
if (!defined($strFileName))
|
||||||
|
{
|
||||||
|
confess &log(ASSERT, 'filename must be provided');
|
||||||
|
}
|
||||||
|
|
||||||
# Load the manifest if a filename is provided
|
# Set variables
|
||||||
if (defined($strFileName))
|
$self->{oManifest} = {};
|
||||||
|
$self->{strFileName} = $strFileName;
|
||||||
|
|
||||||
|
# Load the manifest if specified
|
||||||
|
if (!(defined($bLoad) && $bLoad == false))
|
||||||
{
|
{
|
||||||
ini_load($strFileName, $self->{oManifest});
|
ini_load($strFileName, $self->{oManifest});
|
||||||
}
|
}
|
||||||
@ -80,18 +88,15 @@ sub new
|
|||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
# SAVE
|
# SAVE
|
||||||
#
|
#
|
||||||
# Save the config file.
|
# Save the manifest.
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
# sub save
|
sub save
|
||||||
# {
|
{
|
||||||
# my $self = shift;
|
my $self = shift;
|
||||||
# my $strFileName = shift; # Filename to save manifest to
|
|
||||||
#
|
# Save the config file
|
||||||
# # Save the config file
|
ini_save($self->{strFileName}, $self->{oManifest});
|
||||||
# ini_save($strFileName, $self);
|
}
|
||||||
#
|
|
||||||
# return $self;
|
|
||||||
# }
|
|
||||||
|
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
# GET
|
# GET
|
||||||
|
Loading…
Reference in New Issue
Block a user